From 6acdcd5083eabd182ee722d70bc74f4775178f6b Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Tue, 29 Sep 2020 21:49:03 +0800 Subject: [PATCH] =?UTF-8?q?P1724=20=E4=B8=9C=E9=A3=8E=E8=B0=B7=E6=97=A9?= =?UTF-8?q?=E8=8B=97=20[60'=20Code]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R39033232 --- problem/P1724/P1724.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 problem/P1724/P1724.cpp diff --git a/problem/P1724/P1724.cpp b/problem/P1724/P1724.cpp new file mode 100644 index 00000000..8904433b --- /dev/null +++ b/problem/P1724/P1724.cpp @@ -0,0 +1,23 @@ +#include + +using namespace std; + +int main() { + int x = 0, y = 0, t = 0, i = 0; + string s; + cin >> s >> t; + while (t--) { + if (i >= s.size()) { + i = 0; + } + 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; +}