Cod sursa(job #2984291)

Utilizator RaduIC12Ciocirlan Radu-Ioan RaduIC12 Data 23 februarie 2023 20:50:38
Problema Sum Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <fstream>

using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");

int n, i, j;
bool ciur[200001];

void solve()
{
    int x, doix, d, a, b, r;
    long long y;
    fin>>x;
    y=4*x;
    for(d=2; d<x-1; ++d ){
        a=x;
        b=d;
        while(b){
            r=a%b;
            a=b;
            b=r;
        }
        if( a == 1)
            y+=1ll*2 * x ;
    }

    fout<<y<<'\n';
}

int main()
{

    for(fin>>n; n; --n)
        solve();
    return 0;
}