Cod sursa(job #1311639)
Utilizator | Data | 8 ianuarie 2015 14:07:38 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <fstream>
using namespace std;
ifstream fin("cifra.in");
ofstream fout("cifra.out");
int uc,uctotal,i,t;
char n,k,j;
int main()
{
fin>>t;
for(i=1;i<=t;i++){
fin>>n;
uctotal = 0;
for(j=1;j<=n;j++){
k = j;
uc = j;
while(k != 1){
uc = (j*uc) % 10;
k = k-1;
}
uctotal += uc;
if (uctotal > 9)
uctotal = uctotal % 10;
}
fout<<uctotal<<"\n";
}
return 0;
}