Topic: GCD
Code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
//double start_time = clock();
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int n;
while(cin >> n && n){
int ans = 0;
for(int i = 1; i < n; i++){
for(int j = i+1; j <= n; j++){
ans += __gcd(i,j);
}
}
cout << ans << endl;
}
return 0;
}
No comments:
Post a Comment