Cod sursa(job #884639)

Utilizator gerd13David Gergely gerd13 Data 21 februarie 2013 09:40:18
Problema Koba Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include<fstream>
using namespace std;
int n, t1, t2, t3,  i, nr;
    long long s;
int main()
{
    ifstream fin("koba.in");
    ofstream fout("koba.out");
    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;
}