- ๋ญ ์ฅ๋ ๊ฐ์ ๋ฌธ์ ..--; ์ฒซ ๋ฌธ์ ๋ผ ๊ทธ๋ฐ๊ฑฐ๊ฒ ์ฃ ?
- STL ์ฐ๋๊น ์ ๋ง ํธํ๋ค์. ์์ผ๋ก ์์ฃผ ์ ์ฉํ ๋ฏ..
~cpp
#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
using namespace std;
bool IsSameCode(const string& comet, const string& group);
int AlphabetToNumber(char ch);
int main()
{
string comet, group;
ifstream fin("ride.in");
ofstream fout("ride.out");
fin >> comet;
fin >> group;
if(IsSameCode(comet, group))
fout << "GO\n";
else
fout << "STAY\n";
fout.close();
fin.close();
return 0;
}
bool IsSameCode(const string& comet, const string& group)
{
long a = 1;
long b = 1;
basic_string<char>::const_iterator i;
for(i = comet.begin() ; i != comet.end() ; ++i)
a *= AlphabetToNumber(*i);
for(i = group.begin() ; i != group.end() ; ++i)
b *= AlphabetToNumber(*i);
return (a%47) == (b%47);
}
int AlphabetToNumber(char ch)
{
return ch - 64;
}