zoj 2886 Look and Say
2011-12-23 12:02
337 查看
//这一题和2478差不多,只不过是字符串变长了,如果用cout频繁输出的情况下就会超时!所以用printf! #include "iostream" #include "string" #include "stdio.h" using namespace std; int main() { int TestCase; cin >> TestCase; while (TestCase--) { string str; char first; int length, count = 0; cin >> str; length = str.size(); first = str[0]; for (int i = 0; i < length; i++) { if (str[i] == first) { count++; if (i == length - 1) printf("%d%c", count, first); } else { printf("%d%c", count, first); first = str[i]; count = 1; if (i == length - 1) printf("%d%c", count, first); } } cout << endl; } }
相关文章推荐
- ZOJ 2886 Look and Say
- ZOJ 2886 — Look and Say(C++)
- 水水水 zoj 2886 Look and Say
- ZOJ 2886 Look and Say
- zoj 2886 Look and Say
- poj 3438 Look and Say
- POJ 3438 Look and Say (水题)
- Sicily 1491 Look and Say
- Look-and-Say 数列
- Look and Say-3438
- POJ3438 ZOJ2886 UVALive3822 Look and Say【数列+水题】
- HDU 1020 Encoding POJ 3438 Look and Say
- PHP look and say 序列
- 关于Look and Say序列的感想
- POJ 3438 Look and Say
- hoj 2603 Look and Say
- POJ 3438 Look and Say(水~)
- HOJ 2603 Look and Say
- poj3438_Look and Say_暴力水
- I00031 Look-and-say sequence