Cod sursa(job #369424)
Utilizator | Data | 28 noiembrie 2009 13:09:08 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.32 kb |
#include<iostream.h>
#include<fstream.h>
fstream in ("cifra.in",ios::in), out("cifra.out",ios::out);
int cifra(long n)
{ long i,j,x,s=0;
for(i=1;i<=n;i++){
x=1;
for(j=1;j<=i;j++)
x=(x%10)*(i%10);
s=s%10+x%10;
}
return s%10;
}
main(){
long int n;
while (! in.eof()){
in>>n;
cout<<cifra(n)<<endl;
}
}