Cod sursa(job #884635)
Utilizator | Data | 21 februarie 2013 09:38:26 | |
---|---|---|---|
Problema | Koba | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include<fstream>
using namespace std;
int main()
{
ifstream fin("koba.in");
ofstream fout("koba.out");
int n, t1, t2, t3, i, nr;
long long s;
fin>>n>>t1>>t2>>t3;
t1=t1%10;
t2=t2%10;
t3=t3%10;
s=t1+t2+t3;
for(i=4; i<=n; i++)
{ nr=(t1+t2+t3)%10;
t1=t2;
t2=t3;
t3=nr;
s+=nr;
}
fout<<s;
fin.close();
fout.close();
return 0;
}