当前位置:网站首页>C language - Blue Bridge Cup - promised score
C language - Blue Bridge Cup - promised score
2022-07-06 02:38:00 【@Xiaoyu~】
Title Description
If the greatest common divisor of the numerator and denominator of a fraction is 1, This fraction is called a reduced fraction .
for example ,3/4 , 5/2 , 1/8 , 7/1 It's all contract scores .
Excuse me, , How many committed scores are there , The numerator and denominator are 1 To 2020 Integer between ( Include 1 and 2020)?
Topic analysis
Violent search , Judge by the greatest common divisor
1. Import header file first
2. Then design a function to find the greatest common factor of molecules , if 1, Then the score is a reduced score
3. The main function with for loop , Bring each number into the numerator and denominator respectively , then num Count
4. The final result is 2481215
5. The attached total code is as follows
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
// Design masure Function to find the greatest common factor between numerator and denominator
int masure(int i, int n)
{
if (n % i == 0)
{
return i;
}
else if (n % i != 0)
{
return masure(n%i,i);
}
}
int main()
{
int num = 0;
int i = 0;
int n = 0;
// use for Loop so that each number is made a numerator and denominator respectively
for (i = 1; i < 2021; i++)
{
for (n = 1; n < 2021; n++)
{
int x = masure(i,n);
// If the greatest common factor is 1, Then the score is a reduced score
if (x==1)
{
//num Number of Statistics
num++;
}
}
}
printf("%d\n", num);
return 0;
}
边栏推荐
- Reset nodejs of the system
- Multiple solutions to one problem, asp Net core application startup initialization n schemes [Part 1]
- High number_ Vector algebra_ Unit vector_ Angle between vector and coordinate axis
- 2345 file shredding, powerful file deletion tool, unbound pure extract version
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 7
- Pat grade a 1033 to fill or not to fill
- Zero basic self-study STM32 wildfire review of GPIO use absolute address to operate GPIO
- Blue Bridge Cup group B provincial preliminaries first question 2013 (Gauss Diary)
- 米家、涂鸦、Hilink、智汀等生态哪家强?5大主流智能品牌分析
- 有没有sqlcdc监控多张表 再关联后 sink到另外一张表的案例啊?全部在 mysql中操作
猜你喜欢
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8
从顶会论文看2022年推荐系统序列建模的趋势
Sword finger offer 30 Stack containing min function
Network Security Learning - Web vulnerabilities (Part 1)
Advanced technology management - what is the physical, mental and mental strength of managers
2345 file shredding, powerful file deletion tool, unbound pure extract version
Minecraft 1.18.1, 1.18.2 module development 22 Sniper rifle
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19
Looking at the trend of sequence modeling of recommended systems in 2022 from the top paper
随机推荐
如何精准识别主数据?
Introduction to robotframework (III) Baidu search of webui automation
How to generate rich text online
剑指 Offer 30. 包含min函数的栈
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24
PMP每日一练 | 考试不迷路-7.5
inherited constructors
550 permission denied occurs when FTP uploads files, which is not a user permission problem
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8
PMP practice once a day | don't get lost in the exam -7.5
一位博士在华为的22年
好用的 JS 脚本
RobotFramework入门(一)简要介绍及使用
[robot library] awesome robots Libraries
Shell script updates stored procedure to database
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19
【无标题】数据库中一条查询SQL执行的过程
[coppeliasim] efficient conveyor belt
JS events (add, delete) and delegates
Looking at the trend of sequence modeling of recommended systems in 2022 from the top paper