Mai intai trebuie sa te autentifici.
Cod sursa(job #1010806)
Utilizator | Data | 15 octombrie 2013 18:55:50 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int fuc(char v[3000])
{
int i,n=0;
for(i=0;i<strlen(v);i++)
{n=n*10+(v[i]-'0');}
return n;}
int fct(int nr)
{int j=1,i;
for(i=1;i<=nr;i++)
{j=j*(nr%10);
j=j%10;}
return j;}
int main()
{int n,x,i,s,c,q[100];
char v[1000][1000];
ifstream f("cifra.in");
ofstream g("cifra.out");
f>>n;
for(i=1;i<=n;i++)
{f>>v[i];
s=0;
c=fuc(v[i]);
for(x=1;x<=c;x++)
{s=s+fct(x);
s=s%10;}
q[i]=s;
}
for(i=1;i<=n;i++)
g<<q[i]<<"\n";
f.close();
g.close();
return 0;
}