Cod sursa(job #877864)

Utilizator BlackLordFMI Alex Oprea BlackLord Data 13 februarie 2013 12:57:24
Problema Koba Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <fstream>
using namespace std;
ifstream f("koba.in");
ofstream g("koba.out");
int n, t1, t2, t3, i, a;
long long s;
int main(){
    f>>n>>t1>>t2>>t3;
    f.close();
    t1=t1%10;
    t2=t2%10;
    t3=t3%10;
    s=t1+t2+t3;
    for(i=4; i<=n; i++)
    {
        a=(t3+t2*t1)%10;
        t1=t2;
        t2=t3;
        t3=a;
        s+=a;
    }
    g<<s<<"\n";
    g.close();
    return 0;
}