Cod sursa(job #75166)

Utilizator XladhenianGrigorita Vlad-Stefan Xladhenian Data 30 iulie 2007 22:01:11
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.13 kb

#include <iostream.h>
#include <fstream.h>
#include <string.h>

/*

 1 ^ 1   ==  1
 2 ^ 2   ==  4
 3 ^ 3   ==  7
 4 ^ 4   ==  6
 5 ^ 5   ==  5
 6 ^ 6   ==  6
 7 ^ 7   ==  3
 8 ^ 8   ==  6
 9 ^ 9   ==  9
10 ^ 10  ==  0
11 ^ 11  ==  1
12 ^ 12  ==  6
13 ^ 13  ==  3
14 ^ 14  ==  6
15 ^ 15  ==  5
16 ^ 16  ==  6
17 ^ 17  ==  7
18 ^ 18  ==  4
19 ^ 19  ==  9
20 ^ 20  ==  0

---------------
            94


*/

int main(void)
{
 fstream f1("cifra.in",ios::in);
 fstream f2("cifra.out",ios::out);
 int a = 0;
 char N_[100];
 int N = 0;
 int T = 0;
 int NR = 0;
 int l = 0;
// long n[] = {1,4,7,6,5,6,3,6,9,0,1,6,3,6,5,6,7,4,9,0};
// long n[20] = {0,1,5,12,18,23,29,32,38,47,47,48,54,57,63,68,74,81,85,94};
 int n[20] = {0,1,5,2,8,3,9,2,8,7,7,8,4,7,3,8,4,1,5,4};
 f1 >> T;
 for (a = 0;a < T;a = a + 1)
  {
   f1 >> N_;
   l = strlen(N_);
//   if (l > 1)
//     {
      N = ((N_[l - 2] - 48) * 10) + (N_[l - 1] - 48);
//     }
//    else
//     {
//      N = (N_[l - 1] - 48);
//     }
   NR = 4 * (N / 20);
   f2 << ((NR + n[N % 20]) % 10) << endl;
  }
 f1.close();
 f2.close();
 return 0;
}