Cod sursa(job #850571)

Utilizator h2g2Ford Prefect h2g2 Data 8 ianuarie 2013 17:10:11
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#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;
}