1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <algorithm> #include <cstdio> #include <cstring> inline int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n; scanf("%d", &n); int ans = 0; for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { for (int k = j + 1; k <= n; ++k) { if (gcd(i, j) == 1 && gcd(j, k) == 1 && gcd(i, k) == 1) { ++ans; } } } } printf("%d\n", ans); return 0; } |
0 of 6 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 6 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
1、当输入为2时,程序并不会执行第 16 行的判断语句。( )
2、将第16行中的&& gcd(i, k)==1删去不会影响程序运行结果。( )
3、当输入的n≥3的时候,程序总是输出一个正整数。( )
4、将第7行的gcd(b,a%b)改为gcd(a,a%b)后,程序可能出现的问题是( )。
5、当输入为8的时候,输出为( )。
6、调用gcd(36,42)会返回( )。
