现在的位置: 首页 > 综合 > 正文

ZOJ3775 ?(>_o)!

2018年02月22日 ⁄ 综合 ⁄ 共 1810字 ⁄ 字号 评论关闭

?(>_o)! is a pseudo-object-oriented programming language. It implements the following commands:

Command Description
? Check whether the character '?' is in the program's source code. If '?' does not exist in the program's source, the hardware will catch fire or explode.
( It tries to match ')', although mismatch of brackets does not matter at all.
> Increase the internal accumulator.
_ Print the program's source code.
o Instantiate an object of a new sub class of the generic super class. Due to the best principles of object hiding, this object cannot be accessed in any way.
) Just matches '('. It's for patient with obsessive-compulsive disorder. However, mismatch of brackets does not matter at all.
! Print "Hello, world!".
Other characters Be treated as comments rather than instruction.

However, it's only another joke programming language. There is even no way to access the accumulator. But it's one of easiest to finish a "Hello world" program or a quine program. A quine is a computer program which takes no input and produces a copy of
its own source code as its only output. Your task is to judge whether a ?(>_o)! program is a quine.

Input

There are multiple test cases. The first line of input is an integer T indicates the number of test cases. For each test case:

There is one line of string represents the source code of a ?(>_o)! program. The program contains no more than 256 characters. The ASCII value of each character is within [32, 126].

Output

For each test case, output "Yes" if it is a quine. Otherwise, output "No".

Sample Input

4
Hello, world!
source_code
source__code
?(>_o)!

Sample Output

Yes
Yes
No
No
#include<stdio.h>
#include<string.h>
int main()
{
    int xhx,gth,t,i;
    char str[1000],holl[100]="Hello, world!";
    scanf("%d",&t);getchar();
    while(t--)
    {
        gets(str);
        xhx=gth=0;
        int len=strlen(str);
        for( i=0;i<len;i++)
        if(str[i]=='_')
            xhx++;
        else if(str[i]=='!')
            gth++;
        if(xhx>1)
        {
            printf("No\n");continue;
        }
        if(xhx==1&>h==0)
        {
            printf("Yes\n");continue;
        }
        char ss[10000];
        int slen=0;
        while(gth--)
        {
            for(i=0;i<13;i++)
            ss[slen++]=holl[i];
        }
        ss[slen]='\0';
        printf("%s\n",(strcmp(ss,str))==0?"Yes":"No");
    }
}
【上篇】
【下篇】

抱歉!评论已关闭.