Cod sursa(job #2390613)
Utilizator | Mihai Teisanu teisanumihai84 | Data | 28 martie 2019 11:07:03 |
---|---|---|---|
Problema | Koba | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <fstream>
using namespace std;
int n, t1_ant, t2_ant, t3_ant, sol, t, i;
int main ()
{
ifstream fin ("koba.in");
ofstream fout ("koba.out");
fin>>n>>t3_ant>>t2_ant>>t1_ant;
t1_ant=t1_ant%10;
t2_ant=t2_ant%10;
t3_ant=t3_ant%10;
sol+=t1_ant+t2_ant+t3_ant;
for (i=4; i<=n; i++)
{
t=(t1_ant+t2_ant*t3_ant)%10;
sol+=t;
t3_ant=t2_ant;
t2_ant=t1_ant;
t1_ant=t;
}
fout<<sol;
}