Cod sursa(job #1045130)
| Utilizator | Data | 30 noiembrie 2013 22:02:54 | |
|---|---|---|---|
| Problema | Sum | Scor | 35 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("sum.in");
ofstream g ("sum.out");
int cmmdc (int x, int y) {
if (y==0) return x;
return cmmdc (y, x%y);
}
void rezolva () {
int x;
f>>x;
int l=2*x, suma=0;
for (int i=1; i<=l; i++) if (cmmdc (x, i)==1) suma+=i;
g<<suma<<'\n';
}
int main () {
int n;
f>>n;
for (int i=1; i<=n; i++) rezolva ();
return 0;
}
