USACO Section 1.1 Your Ride Is Here

/*
ID: lucien23
PROG: ride
LANG: C++
*/


#include<iostream>
#include<fstream>
#include<string>
using namespace std;


int main()
{
ifstream infile("ride.in");
ofstream outfile("ride.out");
string strComet,strGroup;
int valComet=1,valGroup=1;
int numMode=47;


if(!infile || !outfile)
{
cout<<"file operation failure!"<<endl;
return -1;
}
infile>>strComet>>strGroup;


int lenComet=strComet.length();
for (int i=0;i<lenComet;i++)
{
valComet*=strComet[i]-'A'+1;
}
valComet%=numMode;


int lenGroup=strGroup.length();
for (int i=0;i<lenGroup;i++)
{
valGroup*=strGroup[i]-'A'+1;
}
valGroup%=numMode;


if(valComet==valGroup)
{
outfile<<"GO"<<endl;
}else{
outfile<<"STAY"<<endl;
}


return 0;
}


你可能感兴趣的:(C++,USACO)