USACO CHAPTER 1 1.1 Ride 水题

时间:2022-05-27 09:44:07

水题,主要是学习文件输入输出。

 /*
ID: ijustwa1
LANG: C++
TASK: ride
*/
#include<cstdio>
#include<cstring> using namespace std; const int base=;
const int mod=; char s[];
char t[]; int main()
{
FILE *fin=fopen("ride.in","r");
FILE *fout=fopen("ride.out","w"); fscanf(fin,"%s",s);
fscanf(fin,"%s",t);
int sums=;
int sumt=;
for(int i=;s[i]!='\0';i++)
{
sums*=(s[i]-''-base);
}
sums%=mod;
for(int i=;t[i]!='\0';i++)
{
sumt*=(t[i]-''-base);
}
sumt%=mod; if(sums==sumt)
{
fprintf(fout,"GO\n");
//fprintf(stdout,"GO\n");
}
else
{
fprintf(fout,"STAY\n");
//fprintf(stdout,"STAY\n");
}
return ;
}