0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

P1724 东风谷早苗

R39244100
This commit is contained in:
Baoshuo Ren 2020-10-04 16:09:06 +08:00 committed by Baoshuo Ren
parent a333d24910
commit e513f5cc33
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -1,22 +1,31 @@
// R39244100
#include <bits/stdc++.h>
using namespace std;
int x = 0, y = 0, t = 0;
string s;
int main() {
int x = 0, y = 0, t = 0, i = 0;
string s;
cin >> s >> t;
while (t--) {
if (i >= s.size()) {
i = 0;
}
for (int i = 0; i < s.size(); i++) {
switch (s[i]) {
case 'E': x++; break;
case 'S': y--; break;
case 'W': x--; break;
case 'N': y++; break;
}
}
x *= (int)(t / s.size());
y *= (int)(t / s.size());
for (int i = 0; i < t % s.size(); i++) {
switch (s[i]) {
case 'E': x++; break;
case 'S': y--; break;
case 'W': x--; break;
case 'N': y++; break;
}
i++;
}
cout << x << ' ' << y << endl;
return 0;