Cod sursa(job #2161811)
Utilizator | Data | 11 martie 2018 20:59:53 | |
---|---|---|---|
Problema | Koba | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <fstream>
using namespace std;
ifstream fin("koba.in");
ofstream fout("koba.out");
int n, ant1, crt, ant2, ant3, s, i;
int main(){
fin>>n>>ant3>>ant2>>ant1;
s = ant3%10 + ant2%10 + ant1%10;
for(i=4;i<=n;i++){
crt = ((ant3%10) * (ant2%10) + ant1%10)%10;
s += crt;
ant3 = ant2;
ant2 = ant1;
ant1 = crt;
}
fout<<s;
return 0;
}