ZOJ3775:?(_o)!
?(>_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
Hint
The output of the four sample programs are {"Hello, world!", "source_code", "source__codesource__code", "?(>_o)!Hello, world!"} respectively. Therefore the first two programs are quines, and the last two are not.
Luckily, there is a '?' in the fourth program, so the hardware will not catch fire or explode during running the fourth program.
这道坑题,题意看了好久,唉,不想多说,其实只要看下划线和感叹号即可
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
#include <stack>
using namespace std;
char s[1000];
int main()
{
int n;
int xia,gan;
cin >> n;
getchar();
while(n--)
{
gets(s);
int len = strlen(s);
xia = gan = 0;
for(int i = 0; i<len; i++)
{
if(s[i] == '_')
xia++;
else if(s[i] == '!')
gan++;
}
if(xia>1)
printf("No\n");
else if(xia == 1 && !gan)
printf("Yes\n");
else if(xia && gan)
printf("No\n");
else
{
int l;
char str[20];
if(len%13)
{
printf("No\n");
}
else if(len == 13)
{
if(!strcmp(s,"Hello, world!"))
printf("Yes\n");
else
printf("No\n");
}
else
{
int flag = 1;
for(int i = 13; i<=len-13; i+=13)
{
if(s[i] == 'H' && s[i+1] == 'e' && s[i+2] == 'l' && s[i+3] == 'l' && s[i+4] == 'o' && s[i+5] == ',' && s[i+6] == ' ' && s[i+7] == 'w' && s[i+8] == 'o' && s[i+9] == 'r' && s[i+10] == 'l' && s[i+11] == 'd' && s[i+12] == '!')
flag == 1;
else
{
flag = 0;
break;
}
}
if(flag)
printf("Yes\n");
else
printf("No\n");
}
}
}
return 0;
}
ZOJ3775:?(_o)!相关推荐
- 攻防世界php2_攻防世界-web2
实验准备: firefox浏览器.php执行环境(比如phpstudy) 打开实验: 代码分析: $_o=strrev($str); 对$str字符串进行 字符反转(比如 abc = cba) 第二 ...
- VIJOS-P1192
VIJOS-P1192 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte 描述 在90000年,青蛙占领了整个宇宙.有一天,两个种族的青蛙在 ...
- php模糊查询的实现方法
模糊检索 指搜索系统自动按照用户输入关键词的同义词进行模糊检索,从而得出较多的检索结果. 模式查询 1. SQL匹配模式 2. 正则表达式匹配模式(一般不推荐使用) SQL匹配模式 1.使用sql匹配 ...
- 大数据技术之_19_Spark学习_07_Spark 性能调优 + 数据倾斜调优 + 运行资源调优 + 程序开发调优 + Shuffle 调优 + GC 调优 + Spark 企业应用案例
大数据技术之_19_Spark学习_07 第1章 Spark 性能优化 1.1 调优基本原则 1.1.1 基本概念和原则 1.1.2 性能监控方式 1.1.3 调优要点 1.2 数据倾斜优化 1.2. ...
- golang大厂面试2
golang大厂面试 滴滴 写个二分查找 以下是一个简单的二分查找算法的 Go 语言实现: package mainimport "fmt"// 二分查找函数 func binar ...
- InstallShield内部库函数
InstallShield内部库函数 下载资源:点击 1 库函数综述 InstallShield包含300多个内部库函数,用户可在安装脚本中调用它们来创建程序组,操作文件夹,处理目录,监督安装状态, ...
- ZOJ3775 ?(_o)!
?(>_o)! is a pseudo-object-oriented programming language. It implements the following commands: C ...
- 编程进阶,学会使用_I、_O、_IO,以及volatile const的意义
_I._O._IO在ST库里面的定义是: #define __I volatile const /*!< defines 'read only' permissions */ #define ...
- XCTF-高手进阶区:web2
题目: <?php $miwen="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";functio ...
最新文章
- html中content属性,CSS3的content属性用法详解
- 腾讯云推出竞价实例 云服务器开销最高下降90%
- 08 | 案例篇:系统中出现大量不可中断进程和僵尸进程怎么办?(下)
- 使用Hexo搭建博客,备份至GitHub过程(基于网上资料的实践操作)
- Reservoir Computing: Harnessing a Universal Dynamical System
- django再windows下测试命令总结
- 20200421:周赛练习题(leetcode148周周赛上)
- cisco用户隔离配置
- JVM - 类加载器
- 图片裁切批处理_Imgbot 在线图片批量处理工具 支持缩放、压缩、裁切、水印等...
- 【矩阵论】矩阵的相似标准型(4)(5)
- 荒野大镖客2无法连接远程计算机,荒野大镖客2pc版常见问题解决办法_常见问题解决方法汇总...
- python随笔:round函数的使用
- 如何用自己的笔记本建wifi热点~~~
- 天美生物在美上市背后:财务报表存在重大缺陷,胡永卫持股34%
- 自动文摘评测方法:Rouge-L、Rouge-N
- 蓝桥杯 BASIC-3:字母图形
- 哈佛凌晨4点半的景象
- Win10无法输入中文的解决方法
- slickedit字体设置——使用 Verdana 字体