Daily Questions (Ninety-five)
The 11th Blue Bridge Cup C Language Group B Provincial Competition Exercise B: Conventional score (5')
C++ code:
#include<iostream>
using namespace std;
int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}
int main()
{
int sum = 0;
//分子分母相同的情况
sum = 1;
int sum2 = 0;
//分子小于分母的情况
for(int i = 1; i < 2020; i++)
{
for(int j = i + 1; j <= 2020; j++)
{
if(gcd(i, j) == 1)
{
sum2++;
}
}
}
sum += sum2 * 2;
cout << sum << endl;
return 0;
}
Operation result:
So the answer is:
2481215
note! Some people will count the same denominator and numerator as different, such as 1/1, 2/2, 3/3, ..., 2020/2020, and think that there are 2020 approximate scores with the result of 1, so the answer and standard The answer is different. Know that since the title says it is a score, then at most consider the possibility that it is 1 once!