每日一题第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;
}
相关推荐
2401_892070981 天前
【Linux C++ 日志系统实战】LogFile 日志文件管理核心:滚动策略、线程安全与方法全解析
linux·c++·日志系统·日志滚动
yuzhuanhei1 天前
Visual Studio 配置C++opencv
c++·学习·visual studio
一轮弯弯的明月1 天前
贝尔数求集合划分方案总数
java·笔记·蓝桥杯·学习心得
不爱吃炸鸡柳1 天前
C++ STL list 超详细解析:从接口使用到模拟实现
开发语言·c++·list
十五年专注C++开发1 天前
RTTR: 一款MIT 协议开源的 C++ 运行时反射库
开发语言·c++·反射
‎ദ്ദിᵔ.˛.ᵔ₎1 天前
STL 栈 队列
开发语言·c++
2401_892070981 天前
【Linux C++ 日志系统实战】高性能文件写入 AppendFile 核心方法解析
linux·c++·日志系统·文件写对象
郭涤生1 天前
STL vector 扩容机制与自定义内存分配器设计分析
c++·算法
༾冬瓜大侠༿1 天前
vector
c语言·开发语言·数据结构·c++·算法
cccyi71 天前
【C++ 脚手架】etcd 的介绍与使用
c++·服务发现·etcd·服务注册