Started my programming training.
Problem can be found here here
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| /*
ID: chinux1
PROG: ride
LANG: C++11
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
unsigned long mod47(string name)
{
unsigned long groupNumber = 1;
for (int i = 0; i < 6 && i < name.length(); i++) {
groupNumber = groupNumber * (name[i] - 64);
}
return groupNumber % 47;
}
int main() {
ofstream fout ("ride.out");
ifstream fin ("ride.in");
string a, b;
fin >> a >> b;
if (mod47(a) == mod47(b)) {
fout << "GO" << endl;
} else {
fout << "STAY" << endl;
}
return 0;
}
|