当前位置:网站首页>蓝桥历届真题-既约分数
蓝桥历届真题-既约分数
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
请按任意键继续. . .
边栏推荐
猜你喜欢
随机推荐
NC40 链表相加(二)
Record the system calls and C library functions used in this project-2
glibc 内存管理模型 释放 C库内存缓存
puzzle(016.5)逻辑电路
eslint语法规则报错
Clock frequency and baud rate count for serial communication in FPGA
FFmpeg多媒体文件处理(ffmpeg打印音视频Meta信息)
render解析
万物皆可柯里化的 Ramda.js
Q_07 词汇表
Jenkins API groovy calling practice: Jenkins Core Api & Job DSL to create a project
Process/Thread Related in Sandbox - 2
The FPGA - work summary recently
handwritten big pile
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 14 Assignment
Sandbox中的进程/线程相关-2
陈强教授《机器学习及R应用》课程 第十三章作业
FFmpeg多媒体文件处理(FFMPEG日志系统)
CPU-MIPS32 instruction architecture (unlocked pipeline microprocessor)
面试攻略系列(三)-- 高级开发工程师面试问些啥?

![[极客大挑战 2019]Upload](/img/ed/062a89797c790189d9bd77b50335b0.png)


![[MRCTF2020]套娃-1](/img/cb/ba780a4929acd9d76f77ab269faff6.png)



