第一个样例测完不对。。。求助

P1724 东风谷早苗

码风好评QAQ
by XLost @ 2019-07-18 17:12:27


@[wwwchen](/space/show?uid=101565) 命令串要循环
by XLost @ 2019-07-18 17:15:17


@[wwwchen](/space/show?uid=101565) 把s[i]改成s[i % n]
by XLost @ 2019-07-18 17:17:26


偷偷告诉你,这样是没法过的QAQ 会超时哦
by renxiaoyu @ 2019-07-18 17:17:40


emmm打错了是str.size()
by XLost @ 2019-07-18 17:19:05


@[renxiaoyu](/space/show?uid=196949) emmm没看数据范围QAQ
by XLost @ 2019-07-18 17:21:11


@[wwwchen](/space/show?uid=101565) 要这样 ```cpp #include <bits/stdc++.h> std::string str; long long n; int nx, ny, x, y, tot, els; int main() { std::cin >> str >> n; for(int i = 0; i < str.size(); i++) { if(str[i] == 'E') { x++; } if(str[i] == 'S') { y--; } if(str[i] == 'W') { x--; } if(str[i] == 'N') { y++; } } tot = n / str.size(); els = n % str.size(); for(int i = 1; i <= tot; i++) { nx += x; ny += y; } for(int i = 0; i < els; i++) { if(str[i] == 'E') { nx++; } if(str[i] == 'S') { ny--; } if(str[i] == 'W') { nx--; } if(str[i] == 'N') { ny++; } } std::cout << nx << ' ' << ny << std::endl; return 0; } ```
by XLost @ 2019-07-18 17:28:13



by wwwchen @ 2019-07-22 11:00:36


|