九度OJ--1006-ZOJ问题
2015-03-20 17:14
330 查看
#include <stdio.h> #include <string.h> int main(int argc, char* argv[]) { char str[1000]; int front, middle, behind, N; int count_z = 0, count_j = 0;//记录zj的个数 int index_z = -1, index_j = -1;//记录zj的位置 int i; while(EOF != scanf("%s",str)) { //查找ZJ的位置,并记录其前中后有多少个o字符 index_j = -1; index_z = -1; count_j = 0; count_z = 0; for(i = 0; i < strlen(str); ++i) { if (str[i] == 'z') { index_z = i; count_z++; } if (str[i] == 'j') { index_j = i; count_j++; } } //如果count>1或者index中有一个为-1,则WA if (count_j > 1 | count_z > 1 | index_z == -1 | index_j == -1 | index_j < index_z) { printf("Wrong Answer\n"); continue; } else {//计算前中后的‘o’的个数 front = index_z; middle = index_j - index_z - 1; behind = strlen(str) - index_j - 1; if (middle >= 1 && front*middle == behind) { printf("Accepted\n"); continue; } else { printf("Wrong Answer\n"); continue; } } } return 0; } /************************************************************** Problem: 1006 User: tenyee Language: C Result: Accepted Time:30 ms Memory:912 kb ****************************************************************/时间有点长了,后面想想哪占了这么多时间吧
相关文章推荐
- 九度OJ 1006:ZOJ问题 (递归)
- 九度OJ 1006 ZOJ问题
- 九度oj 题目1006:ZOJ问题 【ZJU2010考研机试题2】【容易理解混乱】
- 九度OJ 1006:ZOJ问题 (递归)
- 九度 oj 题目1006:ZOJ问题
- 九度考研真题 浙大 2010-2浙大1006:ZOJ问题
- 九度1006 ZOJ问题 浙大考研机试题
- 题目1006:ZOJ问题(递推规律)
- 九度 题目1006:ZOJ问题
- 九度OJ 1006 ZOJ问题 (这题测试数据有问题)
- 题目1006:ZOJ问题
- 浙大ZOJ 1006 Do the Untwist问题解决及其他人的解决方法
- [Jobdu OJ] 1006 ZOJ问题
- 题目1006:ZOJ问题
- 九度:1006<ZOJ问题><规则,规律>
- zoj问题 九度1006&&hdu3788(字符串)
- 题目1006:ZOJ问题
- 9度oj 题目1006:ZOJ问题【递推】
- 1006 ZOJ问题 九度Online Judge
- 题目1006:ZOJ问题