Cod sursa(job #2487393)

Utilizator betybety bety bety Data 4 noiembrie 2019 18:01:55
Problema Sum Scor 45
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <fstream>
#include <algorithm>
using namespace std;
int main()
{
    ifstream in("sum.in");
    ofstream out("sum.out");
    int n;
    in>>n;
    for(int w=1;w<=n;++w)
    {
        int x;
        long long int s=0,cnt=0;
        in>>x;
        for(int i=1;i<=x-1;++i)
            if(__gcd(i,x)==1)
            s+=1LL*i,cnt++;
        out<<2*s+cnt*(1LL*x)<<endl;
    }
    return 0;
}