每日一题第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;
}
相关推荐
程序员zgh1 天前
C++ 互斥锁、读写锁、原子操作、条件变量
c语言·开发语言·jvm·c++
獭.獭.1 天前
C++ -- STL【unordered_set和unordered_map的使用】
c++·stl·unordered_map·unordered_set
star _chen1 天前
C++ std::move()详解:从小白到高手
开发语言·c++
福尔摩斯张1 天前
C++核心特性精讲:从C语言痛点出发,掌握现代C++编程精髓(超详细)
java·linux·c语言·数据结构·c++·驱动开发·算法
charlie1145141911 天前
如何快速在 VS2026 上使用 C++ 模块 — 完整上手指南
开发语言·c++·笔记·学习·现代c++
报错小能手1 天前
STL_unordered_map
开发语言·c++·哈希算法
历程里程碑1 天前
C++ 9 stack_queue:数据结构的核心奥秘
java·开发语言·数据结构·c++·windows·笔记·算法
仰泳的熊猫1 天前
1108 Finding Average
数据结构·c++·算法·pat考试
AA陈超1 天前
虚幻引擎5 GAS开发俯视角RPG游戏 P07-18.生成火球术
c++·游戏·ue5·游戏引擎·虚幻
wxin_VXbishe1 天前
springboot居家养老管理系统-计算机毕业设计源码55953
java·c++·spring boot·python·spring·django·php