当前位置:网站首页>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;
}边栏推荐
- HDU_ p1237_ Simple calculator_ stack
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 17
- SQL table name is passed as a parameter
- Follow the mouse's angle and keyboard events
- 一个复制也能玩出花来
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 10
- Redis cluster deployment based on redis5
- UE4 - how to make a simple TPS role (I) - create a basic role
- Dachang image library
- [coppeliasim] efficient conveyor belt
猜你喜欢

Referenceerror: primordials is not defined error resolution

Building the prototype of library functions -- refer to the manual of wildfire
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16](/img/c3/f3746b161012acc3751b2bd0b8f663.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
![[Wu Enda machine learning] week5 programming assignment EX4 - neural network learning](/img/37/83953c24ec141667b304f9dac440f1.jpg)
[Wu Enda machine learning] week5 programming assignment EX4 - neural network learning

Minecraft 1.16.5 biochemical 8 module version 2.0 storybook + more guns

UE4 - how to make a simple TPS role (I) - create a basic role

Master data management theory and Practice
![[untitled] a query SQL execution process in the database](/img/de/700ee20934fc2cd4a019f761148ef9.png)
[untitled] a query SQL execution process in the database

Easy to use js script
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15](/img/72/0fe9cb032339d5f1ccf6f6c24edc57.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
随机推荐
Number conclusion LC skimming review - 1
Differences and usage scenarios between TCP and UDP
好用的 JS 脚本
General process of machine learning training and parameter optimization (discussion)
一个复制也能玩出花来
Yyds dry inventory comparison of several database storage engines
米家、涂鸦、Hilink、智汀等生态哪家强?5大主流智能品牌分析
[postgraduate entrance examination English] prepare for 2023, learn list5 words
Blue Bridge Cup group B provincial preliminaries first question 2013 (Gauss Diary)
Accident index statistics
ReferenceError: primordials is not defined错误解决
2022.02.13
High number_ Vector algebra_ Unit vector_ Angle between vector and coordinate axis
"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.3 linear algebra_ Learning thinking and exercise answers
07 单件(Singleton)模式
从顶会论文看2022年推荐系统序列建模的趋势
【MySQL 15】Could not increase number of max_open_files to more than 10000 (request: 65535)
Pure QT version of Chinese chess: realize two-man, man-machine and network games
Bigder: I felt good about the 34/100 interview, but I didn't receive the admission
Pat grade a 1033 to fill or not to fill