Cod sursa(job #358004)

Utilizator kojocojocaru aurelian kojo Data 21 octombrie 2009 17:36:53
Problema Koba Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.32 kb
#include<fstream.h>
ifstream f("koba.in");
ofstream g("koba.out");
long i,p,s,n,t1,t2,t3;

long gener(long a,long b,long c)
{return (c+b*a)%10;}
int main()
{
f>>n>>t1>>t2>>t3;
s=t1%10+t2%10+t3%10;
   for(i=1;i<=n-3;i++)
     {p=gener(t1,t2,t3);
      s+=p%10;
      t1=t2;t2=t3;t3=p;
     }
g<<s;
 return 0;
}