Pagini recente » Cod sursa (job #1102935) | Cod sursa (job #810896) | Cod sursa (job #85035) | Cod sursa (job #278022) | Cod sursa (job #850571)
Cod sursa(job #850571)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <deque>
#include <stack>
#define tmax 30005
using namespace std;
int main() {
ifstream f("cifra.in");
ofstream g("cifra.out");
int test, t, i, j, nr, a, b, lung, sol;
string s;
int v[] = {0, 1, 4, 7, 6, 5, 6, 3, 6, 9};
f>>t; f.get();
for(test=1; test<=t; test++) {
getline(f,s);
lung = s.length();
a = 0;
b = int(s[lung-1]) - 48;
if(lung > 1) a = int(s[lung-2]) - 48;
nr = 10 * a + b;
sol = 0;
for(i=1; i<=nr; i++) sol += v[i%10];
g<<sol%10<<"\n";
}
return 0;
}