博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 3096:Surprising Strings
阅读量:6896 次
发布时间:2019-06-27

本文共 1886 字,大约阅读时间需要 6 分钟。

Surprising Strings
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6258   Accepted: 4072

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

ZGBGXEEAABAABAAABBBCBABCC*

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.

大水题,判断一个字符串中的两个字符组是否相等,一开始是连着的两个字符组,然后看隔一个,隔两个。。。

题目分类上说是考察STL的用法。

代码:

#include 
#include
#include
#include
#include
#include
using namespace std;vector
zifu;bool pend(){ int m = zifu.size(); int i,j; for(i=0;i
>a) { if(a=="*") break; len=a.length(); int flag=1; for(k=1;k

版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/lightspeedsmallson/p/4785838.html

你可能感兴趣的文章
一个提供jsp免费空间的站点
查看>>
2014Esri全球用户大会之标准和互操作
查看>>
[歪谈]“走形式”的会议要不要滚粗
查看>>
wordpress表结构
查看>>
关于删除 hao123 主页设置的一点经验
查看>>
快速排序
查看>>
浅析Java虚拟机结构与机制[转]
查看>>
具体解释Android中AsyncTask的使用
查看>>
谷歌“信息安全公主”:我是一名好黑客
查看>>
Web Service学习笔记
查看>>
windows无法搜索新更新 80072ee2
查看>>
win7 32/64bit VS2010 OpenCV 2.4.9 环境配置
查看>>
tomcat配置虚拟主机
查看>>
【百度地图API】百度API卫星图使用方法和卫星图对比工具
查看>>
XCode中使用SVN 教程
查看>>
Guice--Java依赖注入框架
查看>>
第二、UIScrollView的使用大全
查看>>
Ehcache(03)——Ehcache中储存缓存的方式
查看>>
基于海康监控的图像识别设计
查看>>
Senparc.Weixin.MP SDK 微信公众平台开发教程(十五):消息加密
查看>>