poj3096
C++的标准模版库的应用
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 6625 | Accepted: 4309 |
Description
The D-pairs of a string of letters are the ordered pairs of letters that are distance D from each other. A string is D-unique if all of its D-pairs are different. A string is surprising if it is D-unique for every possible distance D.
Consider the string ZGBG. Its 0-pairs are ZG, GB, and BG. Since these three pairs are all different, ZGBG is 0-unique. Similarly, the 1-pairs of ZGBG are ZB and GG, and since these two pairs are different, ZGBG is 1-unique. Finally, the only 2-pair of ZGBG is ZG, so ZGBG is 2-unique. Thus ZGBG is surprising. (Note that the fact that ZG is both a 0-pair and a 2-pair of ZGBG is irrelevant, because 0 and 2 are different distances.)
Acknowledgement: This problem is inspired by the "Puzzling Adventures" column in the December 2003 issue of Scientific American.
Input
The input consists of one or more nonempty strings of at most 79 uppercase letters, each string on a line by itself, followed by a line containing only an asterisk that signals the end of the input.
Output
For each string of letters, output whether or not it is surprising using the exact output format shown below.
Sample Input
- ZGBG
- X
- EE
- AAB
- AABA
- AABB
- BCBABCC
- *
Sample Output
- ZGBG is surprising.
- X is surprising.
- EE is surprising.
- AAB is surprising.
- AABA is surprising.
- AABB is NOT surprising.
- BCBABCC is NOT surprising.
Source

- #include<cstdio>
- #include<cstring>
- char str[];
- int main(){
- int i,j,k;
- int count;
- int len;
- while(scanf("%s",str)==&&strcmp(str,"*")!=){
- len=strlen(str);
- if(len<=){
- printf("%s is surprising.\n", str);
- continue;
- }
- for(i=,count=;i<len&&count!=; i++){
- count=;
- for(j=i+,k=;j<len;j++,k++){
- if(str[j]==str[k]) count++;
- if(count==) break;
- }
- }
- if(count==)
- printf("%s is NOT surprising.\n", str);
- else
- printf("%s is surprising.\n", str);
- }
- return ;
- }
poj3096的更多相关文章
- [POJ3096]Surprising Strings
[POJ3096]Surprising Strings 试题描述 The D-pairs of a string of letters are the ordered pairs of letters ...
- POJ3096:Surprising Strings(map)
http://poj.org/problem?id=3096 for循环真是奇妙! #include <string.h> #include <stdio.h> #includ ...
- poj分类 很好很有层次感。
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
- 【转】POJ题目分类推荐 (很好很有层次感)
OJ上的一些水题(可用来练手和增加自信) (poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094)初期: 一. ...
- 【转】ACM训练计划
[转] POJ推荐50题以及ACM训练方案 -- : 转载自 wade_wang 最终编辑 000lzl POJ 推荐50题 第一类 动态规划(至少6题, 和 必做) 和 (可贪心) (稍难) 第二类 ...
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- acm常见算法及例题
转自:http://blog.csdn.net/hengjie2009/article/details/7540135 acm常见算法及例题 初期:一.基本算法: (1)枚举. (poj17 ...
- poj分类
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
随机推荐
- docker集群——介绍Mesos+Zookeeper+Marathon的Docker管理平台
容器为用户打开了一扇通往新世界的大门,真正进入这个容器的世界后,却发现新的生态系统如此庞大.在生产使用中,不论个人还是企业,都会提出更复杂的需求.这时,我们需要众多跨主机的容器协同工作,需要支持各种类 ...
- Ubuntu14.04使用samba服务器共享Home目录
这里记录一下,以Ubuntu 14.04为例. 1.安装samba服务器. sudo apt-get install samba 2.修改配置文件 sudo vim /etc/samba/smb. ...
- 【转】Python——编码规范
来自于 啄木鸟社区 Python Coding Rule --- hoxide 初译 dreamingk 校对发布 040724 --- xyb 重新排版 040915 --- ZoomQuiet M ...
- 《深入理解jvm》笔记---第七章
虚拟机类载入机制 1. 类的生命周期: 载入.验证.准备.解析.初始化.使用.卸载七个阶段.当中验证.准备.解析三个阶段统称为连接. 当中,解析的阶段的时机并不一定. 2. Java类载入的时机: J ...
- jquery 事件,注册 与重复事件处理
jquery有时候会出现重复注册一个事件的问题,导致点击一个事件,这个事件被重复执行,也就是触发事件的次数有几次, 那么这个事件就会被执行叠加重复几次. 我这边做的一个项目,在某个页面初始化的时候,给 ...
- WireShake的使用
转自点击打开链接 之前写过一篇博客:用 Fiddler 来调试HTTP,HTTPS. 这篇文章介绍另一个好用的抓包工具wireshark, 用来获取网络数据封包,包括http,TCP,UDP,等网络协 ...
- Python-PyQt安装
Windows下安装PyQt需要使用 mingw32-make工具, 以在windows下make
- duplicate symbols 错误解决方案
duplicate symbols for architecture arm64 after xCode 8.0 update 升级xcode 8以后提示有的变量重复了,只要在 Build setti ...
- destoon二次开发基础指南
代码首先包含common.inc.php文件 在common.inc.php文件中,首先定义常量. define('IN_DESTOON', true); define('IN_ADMIN', def ...
- systemd 管理python 程序
[Unit] Description = test-minapp After = network.target [Service] PermissionsStartOnly = true PIDFil ...