每日一题第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;
}
相关推荐
Dream it possible!19 小时前
LeetCode 面试经典 150_二叉搜索树_二叉搜索树的最小绝对差(85_530_C++_简单)
c++·leetcode·面试
麦烤楽鸡翅20 小时前
简单迭代法求单根的近似值
java·c++·python·数据分析·c·数值分析
sulikey21 小时前
C++ 四十年:一段跨越时代的语言旅程
c++·c++40周年
-森屿安年-1 天前
LeetCode 283. 移动零
开发语言·c++·算法·leetcode
散峰而望1 天前
C++数组(一)(算法竞赛)
c语言·开发语言·c++·算法·github
FuckPatience1 天前
C++ 常用类型写法和全称
开发语言·c++
__BMGT()1 天前
参考文章资源记录
开发语言·c++·qt
ouliten1 天前
C++笔记:std::string_view
开发语言·c++·笔记
玫瑰花店1 天前
万字C++中锁机制和内存序详解
开发语言·c++·算法
D_evil__1 天前
[C++高频精进] 文件IO:文件流
c++