Cod sursa(job #274644)
Utilizator | Data | 9 martie 2009 21:43:19 | |
---|---|---|---|
Problema | Koba | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.27 kb |
#include <fstream.h>
ifstream f("koba.in");
ofstream g("koba.out");
int main()
{
long long n,t[1000000],i,s=0;
f>>n>>t[1]>>t[2]>>t[3];s=t[1]%10+t[2]%10+t[3]%10;
for(i=4;i<=n;i++)
{ t[i]=(t[i-1]+(t[i-2]*t[i-3]))%10;
s+=t[i]%10;
}
g<<s;
return 0;
}