当前位置:网站首页>蓝桥历届真题-既约分数
蓝桥历届真题-既约分数
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
请按任意键继续. . .
边栏推荐
- ftplib+ tqdm upload and download progress bar
- 5G China unicom AP:B SMS ASCII 转码要求
- R language kaggle game data exploration and visualization
- 5G China unicom general exception handling
- Explanation of RTSP protocol
- WPF 系统托盘 图标闪烁
- Map mixed density function and quantile added line
- 用plot_hist_numeric()实现画直方图
- 现在40系显卡都快出来了,为何1060型号的显卡还有这么多人用?
- Professor Chen Qiang's "Machine Learning and R Application" course Chapter 15 Homework
猜你喜欢
Jenkins API groovy calling practice: Jenkins Core Api & Job DSL to create a project
七夕力扣刷不停,343. 整数拆分(剑指 Offer 14- I. 剪绳子、剑指 Offer 14- II. 剪绳子 II)
GIN Bind mode to get parameters and form validation
IDEA Gradle 常遇问题(一)
缓存和数据库一致性问题
Unicom network management protocol block diagram
gin's middleware and routing grouping
关于做2D游戏时,Canvas边界显示在Game窗口的问题
技嘉显卡 RGBFusion 不能调光解决方法
蓝桥杯线上模拟赛——Flex 经典骰子布局
随机推荐
ArcEngine(九)图形绘制
5G China unicom repeater network management protocol real-time requirements
The sword refers to Offer 57 - II. and is a continuous positive sequence of s (sliding window)
Q_04_04 Q#类型模型
offset、client、scroll、window.pageYOffset比较
技嘉显卡 RGBFusion 不能调光解决方法
javscript基础易错点集合
Deep Learning Based on R Language - Simple Regression Case
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 14 Assignment
handwritten big pile
puzzle(016.5)逻辑电路
用plot_hist_numeric()实现画直方图
WSA toolkit installed app store tip doesn't work how to solve?
基于 R 语言的深度学习——简单回归案例
面试攻略系列(三)-- 高级开发工程师面试问些啥?
read stream 特别注意
Anta and Huawei Sports Health jointly verify the champion running shoes and lead Chinese sports with innovation
[MRCTF2020]套娃-1
CPU-MIPS32 instruction architecture (unlocked pipeline microprocessor)
[极客大挑战 2019]Upload