Cod sursa(job #346063)
Utilizator | Porcescu Alexandru TFifes | Data | 6 septembrie 2009 15:27:37 |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<iostream>
#include<fstream>
using namespace std;
int main ()
{
int t,n,j,v[10]={0,1,4,9,6,5,6,9,4,1},s;
ifstream x("cifra.in");
ofstream y("cifra.out");
x>>t;
for(int i=1;i<=t;i++)
{
x>>n;
s=0;
for(j=1;j<=n;j++)
{
s+=v[j%10];
if(j%5==0)
s=s%10;
}
y<<(s%10);
}
x.close();
y.close();
return 0;
}