Cod sursa(job #1398801)

Utilizator teoceltareconstantin teodor teoceltare Data 24 martie 2015 13:31:08
Problema Sum Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#include<iostream>
#include<fstream>
#include<math.h>
using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
int n,x;
void fct()
{
    long long s=0;
    int nr1,nr2,rest;
    for(int a1=1;a1<=x*2;a1++)
    {
        nr1=x;
        nr2=a1;
        rest=1;
        while(rest)
        {
            rest=nr2%nr1;
            nr2=nr1;
            nr1=rest;
        }
        if(nr2==1)
        {
            s+=a1;
        }
    }
    fout<<s<<'\n';
}
void citire()
{
    fin>>n;
    for(int a1=1;a1<=n;a1++)
    {
        fin>>x;
        fct();
    }
}
int main()
{
    citire();
}