Cod sursa(job #1325530)
| Utilizator | Data | 24 ianuarie 2015 00:58:40 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include<stdlib.h>
#include<stdio.h>
#include<fstream>
#include<math.h>
using namespace std;
int main(){
ifstream in; ofstream out;
in.open("cifra.in"); out.open("cifra.out");
out.clear();
int t, no, v[10],s;
string x;
for(int i=1;i<=9;i++)
v[i]=pow(i,i);
in>>t;
for(int i=1;i<=t;i++){
in>>x;
no=x[x.length()-1]-'0';
s=0;
for(int j=1;j<=no; j++)
s=s+v[j]%10;
out<<s%10<<endl;
}
return 0;
}
