Cod sursa(job #2910338)
Utilizator | damian [email protected] | Data | 19 iunie 2022 15:52:33 |
---|---|---|---|
Problema | Sum | Scor | 35 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("sum.in");
ofstream g("sum.out");
int cmmdc(int a,int b){
int r;
while(b) r=a%b,a=b,b=r;
return a;
}
int main()
{
int x,n;
f>>n;
for(int i=1;i<=n;i++){
f>>x;
long long s=0;
for(int j=1;j<=2*x;j++)
if(cmmdc(j,x)==1) s+=j;
g<<s<<'\n';
}
}