Cod sursa(job #213881)
| Utilizator | Data | 11 octombrie 2008 21:48:21 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int cifra_putere(int x)
{
int c=x;
for(int i=2;i<=x;i++){
c=(c*x)%10;
}
return c;
}
int main(){
int n;
int x;
int s;
ifstream f ("cifra.in");
ofstream g ("cifra.out");
f>>n;
for(int i=1;i<=n;i++){
s=0;
f>>x;
for(int j=1;j<=x;j++){
s=(s+cifra_putere(j))%10;
}
g<<s<<"\n";
}
g<<"\n";
f.close();
g.close();
return 0;
}