Cod sursa(job #719632)
| Utilizator | Data | 21 martie 2012 22:13:22 | |
|---|---|---|---|
| Problema | Koba | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
// koba.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include "fstream"
using namespace std;
int main()
{
ifstream f("koba.in");
ofstream g("koba.out");
int n,t1,t2,t3;
f>>n>>t1>>t2>>t3;
t1%=10;
t2%=10;
t3%=10;
int i,s=0;
s=t1+t2+t3;
if(n>=3)
{
for(i=0;i<n-3;i++)
{
int t4;
t4=(t3+t2*t1)%10;
t1=t2%10;
t2=t3%10;
t3=t4%10;
s+=t4;
}
g<<s;
}
if(n==2)
g<<t1+t2;
if(n==1)
g<<t1;
return 0;
}
