题解 | #ZOJ问题#
ZOJ问题
https://www.nowcoder.com/practice/e132f7aa63bb430494db3644b8ffa860
#include <iostream> #include "string" #include "algorithm" #include "cstring" using namespace std; bool ac(string s) { int n = s.size(); int i = s.find("z"), j = s.find("j"); if(s.rfind("z") != i) return false; if(s.rfind("j") != j) return false; int l = i, mid = j - i - 1, r = n - j - 1; if(mid == 0) return false; while(mid > 1) { mid --; r -= l; } return l == r; } int main() { string s; while (cin >> s) { // 注意 while 处理多个 case if(ac(s)) cout << "Accepted\n"; else cout << "Wrong Answer\n"; } } // 64 位输出请用 printf("%lld")