4000题 求改

Ricardo 2022-04-10 16:21:08 2022-04-10 16:21:58 0

样例都能过

#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,a;
	long long sum1=1,sum2=1;
	cin>>s;
	for(int i=0;i<=s.length()-1;i++){
		sum1*=(s[i]-64);
		sum1%=47;
	}
	cin>>a;
	for(int i=0;i<=a.length()-1;i++){
		sum2*=(a[i]-64);
		sum2%=47;
	}
	if(sum1==sum2){
		printf("GO");
	}
	else printf("STAY");
	return 0;
}
{{ vote && vote.total.up }}

共 2 条回复

luojiajie

freopen是文件重定向,比赛时候是必须写的,格式如下:

freopen("文件名.in","r",stdin);

freopen("文件名.out","w",stdout);

这两句加在主函数的最前面,后面还有两句可写可不写,大概就是关闭输入输出流

fclose(stdin);

fclose(stdout);

luojiajie

#include <bits/stdc++.h>

using namespace std;

int main(){

freopen("ride.in","r",stdin);

freopen("ride.out","w",stdout);

string s;

string a;

long long sum1=1,sum2=1;

cin>>s;

for(int i=0;i<s.length();i++){
	
	sum1*=(s[i]-64);sum1%=47;
	
}

cin>>a;

for(int i=0;i<=a.length()-1;i++){
	
	sum2*=(a[i]-64);
	
	sum2%=47;
	
}
if(sum1==sum2){
	
	printf("GO");
	
}
else printf("STAY");

return 0;

}

//emm其实就是没写freopen

//-----本人代码-------

#include<bits/stdc++.h>

using namespace std;

string a,b;

int i,j,sum1=1,sum2=1;

int main(){

freopen("ride.in","r",stdin);

freopen("ride.out","w",stdout);

cin>>a>>b;

for(i=0;i<a.length();i++) sum1*=((int)a[i]-64);

for(i=0;i<b.length();i++) sum2*=((int)b[i]-64);

if(sum1%47==sum2%47) printf("GO");//cout<<"GO";

else printf("STAY");//cout<<"STAY";

return 0;

}