Cod sursa(job #974864)
| Utilizator | Data | 18 iulie 2013 16:16:49 | |
|---|---|---|---|
| Problema | Sum | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
// Sum.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("sum.in");
ofstream fout ("sum.out");
int n, x, i, j, div_max=0, a, b, rest;
long int sum;
int main()
{
fin>>n;
for (i=1; i<=n; i++) {
sum=0;
fin>>x;
for (j=1; j<2*x; j++) {
rest=1;
a=j; b=x;
while (rest!=0) {
rest=a%b;
a=b;
b=rest;
}
if (a==1)
sum=sum+j;
}
fout<<sum<<"\n";
}
return 0;
}
