ZOJ问题(杭电3788)

ZOJ问题

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 2859    Accepted Submission(s): 862

Problem Description

对给定的字符串(只包含‘z‘,‘o‘,‘j‘三种字符),判断他是否能AC。

是否AC的规则如下:

1. zoj能AC;

2. 若字符串形式为xzojx,则也能AC,其中x可以是N个‘o‘ 或者为空;

3. 若azbjc 能AC,则azbojac也能AC,其中a,b,c为N个‘o‘或者为空;

Input

输入包含多组测试用例,每行有一个只包含‘z‘,‘o‘,‘j‘三种字符的字符串,字符串长度小于等于1000;

Output

对于给定的字符串,如果能AC则请输出字符串“Accepted”,否则请输出“Wrong Answer”。

Sample Input

zoj
ozojo
ozoojoo
oozoojoooo
zooj
ozojo
oooozojo
zojoooo

Sample Output

Accepted
Accepted
Accepted
Accepted
Accepted
Accepted
Wrong Answer
Wrong Answer

Source

浙大计算机研究生复试上机考试-2010年

//a*b==c即Aceeptd,a表示z之前o的个数,
//b表示zj之间o的个数,c表示j之后o个数
#include<stdio.h>
#include<string.h>
char s[1002];
int main()
{
	int i,len,a,b,c,d,e;
	while(scanf("%s",s)!=EOF)
	{
		len=strlen(s);
		for(i=0;i<len;i++)
		{
			if(s[i]=='z')
			   a=i;
			if(s[i]=='j')
			   b=i-a-1;
		}
		c=len-a-b-2;
		if(a==0)
		{
		    if(b>0&&c==0)
		    printf("Accepted\n");
		    else
		    printf("Wrong Answer\n");
		}
		else
		{
		    if(a*b==c&&b>0)
		    printf("Accepted\n");
		    else
		    printf("Wrong Answer\n");
		}
	}
	return 0;
} 
时间: 2024-10-07 05:14:04

ZOJ问题(杭电3788)的相关文章

ZOJ(杭电3783)

ZOJ Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1883    Accepted Submission(s): 1334 Problem Description 读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当某个字符用完时,剩下的仍然按照ZOJ的顺序输出. Input 题目包含多组用例,每组用

ZOJ输出 【杭电-3783】 附:2009浙大研究生复试题

/* ZOJ Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1588    Accepted Submission(s): 1129 Problem Description 读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当某个字符用完时,剩下的仍然按照ZOJ的顺序输出. Input 题目包含多组用例,

杭电 1395

2^x mod n = 1 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11658    Accepted Submission(s): 3634 Problem Description Give a number n, find the minimum x(x>0) that satisfies 2^x mod n = 1. In

杭电 HDU 1164 Eddy&#39;s research I

Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7117    Accepted Submission(s): 4268 Problem Description Eddy's interest is very extensive, recently  he is interested in prime

hdu 1016 Prime Ring Problem DFS解法 纪念我在杭电的第一百题

Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 29577    Accepted Submission(s): 13188 Problem Description A ring is compose of n circles as shown in diagram. Put natural num

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

一个人的旅行 HDU杭电2066【dijkstra算法】

http://acm.hdu.edu.cn/showproblem.php?pid=2066 Problem Description 虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景--草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女--眼看寒假就快到了,这么一大段时间,可不

杭电1162--Eddy&#39;s picture(Prim()算法)

Eddy's picture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8070    Accepted Submission(s): 4084 Problem Description Eddy begins to like painting pictures recently ,he is sure of himself to b

杭电1276--士兵队列训练问题

士兵队列训练问题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4605    Accepted Submission(s): 2148 Problem Description 某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行