当前位置:网站首页>蓝桥历届真题-既约分数
蓝桥历届真题-既约分数
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
请按任意键继续. . .
边栏推荐
- 【瑞吉外卖】day05:增、删、改、查分类以及公共字段自动填充
- Deep Learning Based on R Language - Simple Regression Case
- 剑指 Offer 43. 1~n 整数中 1 出现的次数(递归、数学)
- GIN初探,环境安装
- An Offer 21. Adjust the array in order to make odd in even the front (loop invariant)
- 陈强教授《机器学习及R应用》课程 第十四章作业
- 43. The sword refers to Offer 1 ~ 1 the number of occurrences of n integers (recursive, mathematics)
- 【奖励公示】第23期 2022年7月奖励名单公示:社区明星评选 | 新人奖 | 博客同步 | 推荐奖
- Dry+Bean+Dataset R语言数据分析,报告英文
- eslint语法规则报错
猜你喜欢

gin's middleware and routing grouping

IDEA Gradle 常遇问题(一)

Periodic sharing of Alibaba Da Tao system model governance

GIN a preliminary study, the environment is installed

GET POST PUT DELETE request in GIN

kustomize entry example and basic syntax instructions

The sword refers to the offer, cuts the rope 2

IDEA Gradle 常遇问题(二)(持续更新)

缓存和数据库一致性问题

How to reduce the size of desktop icons after the computer is reinstalled
随机推荐
Time series analysis course lab report
Sandbox中的进程/线程相关-1
FFMPEG多媒体文件处理(ffmpeg文件的删除与重命名)
【NVIDIA】Tesla V100安装NVIDIA-Driver驱动程序适配CUDA-Toolkit-11.6
Clock frequency and baud rate count for serial communication in FPGA
offset、client、scroll、window.pageYOffset比较
FFmpeg multimedia file processing (implementation of ffmpeg operation directory and list)
Q_06_02 类型模型
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面(循环不变量)
JS本地存储 sessionStorage和localStorage
NC53 删除链表的倒数第n个节点
5G Unicom Network Management Design Ideas
NFS 特别注意权限的问题
问题系列-如何修改或更新localhost里的值
The sword refers to Offer 57 - II. and is a continuous positive sequence of s (sliding window)
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 14 Assignment
Q_06_04 语句和其他构造
缓存和数据库一致性问题
WPF 实现带蒙版的 MessageBox 消息提示框
Standing wave ratio calculation method