Cod sursa(job #3323639)
| Utilizator | Data | 18 noiembrie 2025 22:04:15 | |
|---|---|---|---|
| Problema | Sum | Scor | 45 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("sum.in");
ofstream g("sum.out");
const int XMAX = 2 * 1e5 + 1;
long long gcd(long long a, long long b){
while(b){
long long r = a % b;
a = b;
b = r;
}
return a;
}
int main(){
int n;
f >> n;
while(n--){
long long x;
f >> x;
int sum = 0;
for(long long i = 1; i <= 2 * x; i++){
if(gcd(i,x) == 1)
sum += i;
}
g << sum << '\n';
}
}
