Cod sursa(job #2912446)
Utilizator | Mihalache Andrei Mihatriceps | Data | 8 iulie 2022 13:23:15 |
---|---|---|---|
Problema | Koba | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("koba.in");
ofstream g("koba.out");
int main()
{
long long n, k, suma=0;
int t1,t2,t3,t4;
f>>n>>t1>>t2>>t3;
t1%=10;
t2%=10;
t3%=10;
if(n==1)
g<<t1;
if(n==2)
g<<t2+t1;
if(n==3)
g<<t3+t2+t1;
if(n>3)
{
suma=suma+t1+t2+t3;
for(k=4;k<=n;k++)
{
t4=(t3%10)+(t2%10)*(t1%10);
t4%=10;
suma+=t4;
t1=t2;
t2=t3;
t3=t4;
}
g<<suma;
}
return 0;
}