Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
很水(附代碼)#include <iostream> #include <string> int score(const std::string &s, int index) { switch (s[index]) { case '.': return 2; case '_': return 0; case '/': --index; while (index >= 0) { switch (s[index]) { case '|': case '\\': return 0; case '.': return 2; } --index; } return 2; case '\\': ++index; while (index < s.length()) { switch (s[index]) { case '|': case '/': return 0; case '.': return 2; } ++index; } return 2; case '|': { int sum = 0; std::string copy = s; copy[index] = '\\'; sum += score(copy, index); copy[index] = '/'; sum += score(copy, index); return sum / 2; } } } int main() { std::ios::sync_with_stdio(false); std::string s; std::cin >> s; while (s != "#") { int sum = 0; for (int i = 0; i < s.size(); ++i) { sum += score(s, i); } std::cout << sum * 100 / (s.size() * 2) << '\n'; std::cin >> s; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator