求找不同
查看原帖
求找不同
1070431
ywtank楼主2024/12/12 20:23
#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int xx=0,yy=0,x=0,y=0;
int main(){
	getline(cin,s,'\n');
	cin >> n;
	for(int i=0;i<s.size();i++){
		if(s[i]=='E')xx++;
		else if(s[i]=='S')yy--;
		else if(s[i]=='W')xx--;
		else if(s[i]=='N')yy++;
	}
	int c=n/s.size();
	x+=(xx*c);
	y+=(yy*c);
	int h=n%s.size();
	for(int i=0;i<h;i++){
		if(s[i]=='E')x++;
		else if(s[i]=='S')y--;
		else if(s[i]=='W')x--;
		else if(s[i]=='N')y++;
	}
	cout << x << ' ' << y;
	return 0;
}

上面代码WA,0pts

2024/12/12 20:23
加载中...