当前位置:网站首页>蓝桥历届真题-既约分数
蓝桥历届真题-既约分数
2022-08-09 13:04:00 【CoolTiger_程序员】

答案:
2481215
思路:
遍历1-2020之间的任意点对,判断gcd是否为1,计数。
使用欧几里得算法(辗转相除法)
#include<stdio.h>
int gcd(int a,int b){
if(b==0) return a;
return gcd(b,a%b);
}
int main(){
int i,j;
int count=0;
for(i=1;i<=2020;i++){
for(j=1;j<=2020;j++){
if(gcd(i,j)==1)
count++;
}
}
printf("%d\n",count);
return 0;
}
2481215
--------------------------------
Process exited after 0.4831 seconds with return value 0
请按任意键继续. . .
边栏推荐
- ArcEngine(九)图形绘制
- 【FPGA教程案例48】图像案例8——基于FPGA的RGB图像转化为HSV图像的实现,通过MATLAB进行辅助验证
- 2.微服务'黑话'集锦及Eureka注册中心相关概念
- Q_04_07 进一步探索
- GIN a preliminary study, the environment is installed
- 蓝桥杯线上模拟赛——Flex 经典骰子布局
- Professor Chen Qiang's "Machine Learning and R Application" course Chapter 13 Assignment
- Professor Chen Qiang's "Machine Learning and R Application" course Chapter 14 Assignment
- 现在40系显卡都快出来了,为何1060型号的显卡还有这么多人用?
- handwritten big pile
猜你喜欢
随机推荐
GIN file upload and return
FFmpeg多媒体文件处理(ffmpeg处理流数据的基本概念)
电脑重装系统后桌面图标如何调小尺寸
npm install失败
JS本地存储 sessionStorage和localStorage
万物皆可柯里化的 Ramda.js
面试攻略系列(四)-- 你不知道的大厂面试
乐东消防救援大队应邀为干部开展消防安全培训
行程和用户[阅读理解法]
An Offer 21. Adjust the array in order to make odd in even the front (loop invariant)
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 14 Assignment
七夕力扣刷不停,343. 整数拆分(剑指 Offer 14- I. 剪绳子、剑指 Offer 14- II. 剪绳子 II)
Oracle Recovery Tools修复空闲坏块
gin的中间件和路由分组
read stream special attention
Q_04_04 Q#类型模型
ArcEngine(九)图形绘制
How to solve the 0x80070005 error when the computer is reinstalled and the system is restored
陈强教授《机器学习及R应用》课程 第十五章作业
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 13 Assignment








