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:
parent
a333d24910
commit
e513f5cc33
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user