URAL 1786 Sandro's Biography
2015-04-27 23:27
507 查看
题意:给你一段字符串,只有大小写字母。魔法师可以改变字符,将一个字母改成另一外一个大小写相同的字母需要花费5,大小写转换也需要花费5,问在文本中如何花费最小让文本中出现’Sandro’这个单词。
解法:数据很小。字符串长度最长200,直接暴力一波就可以了,扫一遍。
解法:数据很小。字符串长度最长200,直接暴力一波就可以了,扫一遍。
#include <iostream> #include <cstring> #include <cstdio> #include <string> #include <algorithm> using namespace std; int main() { char s[220]; while(~scanf("%s",s)) { int len = strlen(s); int ans = 12; for(int i = 0; i < len - 5; i++) { int x = 0; if(s[i] != 'S') { if(s[i] == 's') x++; else if(isupper(s[i])) x++; else x += 2; } if(s[i+1] != 'a') { if(s[i+1] == 'A') x++; else if(islower(s[i+1])) x++; else x += 2; } if(s[i+2] != 'n') { if(s[i+2] == 'N') x++; else if(islower(s[i+2])) x++; else x += 2; } if(s[i+3] != 'd') { if(s[i+3] == 'D') x++; else if(islower(s[i+3])) x++; else x += 2; } if(s[i+4] != 'r') { if(s[i+4] == 'R') x++; else if(islower(s[i+4])) x++; else x += 2; } if(s[i+5] != 'o') { if(s[i+5] == 'O') x++; else if(islower(s[i+5])) x++; else x += 2; } ans = min(ans,x); } printf("%d\n",ans * 5); } return 0; }
相关文章推荐
- URAL - 1786 Sandro's Biography
- URAL 1723 Sandro's Book
- URAL 1786 Sandro's Biography
- Ural 1723. Sandro's Book
- URAL 1723. Sandro's Book(数学啊)
- ural 1671 Anansi's Cobweb-并查集
- ural 2025. Line Fighting -思维题
- [Voronoi图 || 模拟退火 特判 || 圆的离散化] Ural 1520 Empire strikes back
- Ural1387 Vasya's Dad
- ural 1563
- ural 1106
- URAL - 1902 Neo-Venice
- URAL 2070 Interesting Numbers
- Ural2110 : Remove or Maximize
- bzoj 1814: Ural 1519 Formula 1 插头dp经典题
- URAL-1099Work Scheduling
- 51nod 1034 骨牌覆盖 V3 | URAL 1594 Aztec Treasure
- URAL1993-This cheeseburger you don't need
- URAL 1993 This cheeseburger you don't need
- K - Log Files URAL - 2073