Cod sursa(job #335055)

Utilizator iulia609fara nume iulia609 Data 28 iulie 2009 15:21:46
Problema Koba Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include<stdio.h>   
using namespace std;   
 
int main()   
{ int t1,t3,t2,t4;   
  long long n,i,s;   
  
    FILE *f = fopen("koba.in", "r");   
    FILE *g = fopen("koba.out", "w");   
       
    n = 0;   
    fscanf(f, "%lld", &n);   
    fscanf(f, "%d%d%d",&t1,&t2, &t3);   
      
    t1 = t1%10;   
    t2 = t2%10;   
    t3 = t3%10;   
    s = t1+t2+t3;   
    for(i = 4; i <= n; i++)   
        {   
            t4 = (t3 + (t1*t2)%10)%10;   
            t1 = t2;   
            t2 = t3;   
            t3 = t4;   
            s += t4;   
        }   
       
    fprintf(g, "%lld\n", s);   
       
    fclose(f);   
    fclose(g);   
    return 0;   
}