每日一题第15届蓝桥杯c/c++本科B组省赛第2题

cpp 复制代码
#include<iostream>
#include<cmath>
using namespace std;
int gcd(int a, int b) {
	if (a < b) {
		a = a ^ b;
		b = a ^ b;
		a = a ^ b;
		while (b) {
			int t = a % b;
			a = b;
			b = t;
		}
	}
	return a;
}
int main() {
	int x = 343720;
	int y = 233333;
	int dx = 15;
	int dy = 17;
	int p = y * dx;
	int q = x * dy;
	int g = gcd(p, q);
	p /= g;
	q /= g;
	double t = 2 * p * x / dx;
	double res = t * sqrt(pow(dx, 2) + pow(dy, 2));
	printf("%.2lf", res);
	return 0;
}
相关推荐
凡人叶枫1 小时前
Effective C++ 条款30:透彻了解 inlining 的里里外外
linux·开发语言·c++·嵌入式开发·effective c++
noipp1 小时前
推荐题目:洛谷 P10907 [蓝桥杯 2024 国 B] 蚂蚁开会
c语言·c++·算法·编程·洛谷
学逆向的2 小时前
C++纯虚函数
开发语言·c++·网络安全
凡人叶枫3 小时前
Effective C++ 条款22:将成员变量声明为 private
linux·开发语言·c++
坚果派·白晓明4 小时前
【鸿蒙PC】SDL3 移植:AtomCode Skills 4 步速通多媒体库适配
c++·华为·ai编程·harmonyos·atomcode·c/c++三方库
赴生-5 小时前
C++进阶 C++11(下)
开发语言·c++
有点。5 小时前
C++(贪心算法一)
c++·贪心算法
WBluuue5 小时前
数据结构与算法:有序表(二):跳表
数据结构·c++·算法·skiplist
赴生-6 小时前
C++进阶 异常
开发语言·c++
凡人叶枫7 小时前
Effective C++ 条款28:避免使用 handles 指向对象内部
linux·服务器·开发语言·c++·嵌入式开发