标签:
Time Limit: 1000MS | Memory Limit: 65536KB | 64bit IO Format: %I64d & %I64u |
Description
Input
Output
Sample Input
input | output |
---|---|
MyNameIsAlexander |
20 |
枚举就好了。
#include<iostream> #include<algorithm> #include<cctype> using namespace std; int cost1(char c) { if (c == 'S') return 0; if (c == 's'||isupper(c)) return 5; return 10; } int cost2(char c) { if (c == 'a') return 0; if (c == 'A'||islower(c)) return 5; return 10; } int cost3(char c) { if (c == 'n') return 0; if (c == 'N'||islower(c)) return 5; return 10; } int cost4(char c) { if (c == 'd') return 0; if (c == 'D'||islower(c)) return 5; return 10; } int cost5(char c) { if (c == 'r') return 0; if (c == 'R'||islower(c)) return 5; return 10; } int cost6(char c) { if (c == 'o') return 0; if (c == 'O'||islower(c)) return 5; return 10; } int main() { char s[205]; while (cin >> s) { int len = strlen(s); int ans = 60; int temp; for (int i = 0; i < len - 5; i++) { temp = cost1(s[i]) + cost2(s[i + 1]) + cost3(s[i + 2]) + cost4(s[i + 3]) + cost5(s[i + 4]) + cost6(s[i + 5]); ans = min(ans, temp); } cout << ans << endl; } }
URAL - 1786 Sandro's Biography
标签:
原文地址:http://blog.csdn.net/qq_18738333/article/details/45141983