A. Hongcow Learns the Cyclic Shift

题目连接:

http://codeforces.com/contest/745/problem/A

Description

Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.

Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.

Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.

Input

The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').

Output

Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.

Sample Input

abcd

Sample Output

4

Hint

题意

给你一个环形字符串,问里面有多少个长度为n的不同字符串。

题解:

数据范围大一点的话,就是智障后缀数组题。

至于这道题数据范围这么小…… 随便搞一搞就好了

代码

#include<bits/stdc++.h>
using namespace std; string s;
set<string>S;
int main()
{
cin>>s;int len = s.size();
for(int i=0;i<len;i++)
s+=s[i];
for(int i=0;i<len;i++){
string tmp;
for(int j=0;j<len;j++)
tmp+=s[i+j];
S.insert(tmp);
}
cout<<S.size()<<endl;
}

Codeforces Round #385 (Div. 2) A. Hongcow Learns the Cyclic Shift 水题的更多相关文章

  1. Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)

    B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  2. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题

    A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Do ...

  3. Codeforces Round #385 (Div. 2) B - Hongcow Solves A Puzzle 暴力

    B - Hongcow Solves A Puzzle 题目连接: http://codeforces.com/contest/745/problem/B Description Hongcow li ...

  4. Codeforces Round #385 (Div. 1) C. Hongcow Buys a Deck of Cards

    地址:http://codeforces.com/problemset/problem/744/C 题目: C. Hongcow Buys a Deck of Cards time limit per ...

  5. Codeforces Round #385 (Div. 2) C - Hongcow Builds A Nation

    题目链接:http://codeforces.com/contest/745/problem/C 题意:给出n个点m条边,还有k个不能连通的点,问最多能添加几条边. 要知道如果有n个点最多的边是n*( ...

  6. Codeforces Round #396 (Div. 2) A. Mahmoud and Longest Uncommon Subsequence 水题

    A. Mahmoud and Longest Uncommon Subsequence 题目连接: http://codeforces.com/contest/766/problem/A Descri ...

  7. Codeforces Round #375 (Div. 2) A. The New Year: Meeting Friends 水题

    A. The New Year: Meeting Friends 题目连接: http://codeforces.com/contest/723/problem/A Description There ...

  8. Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game 水题

    C. Predict Outcome of the Game 题目连接: http://codeforces.com/contest/451/problem/C Description There a ...

  9. Codeforces Round #359 (Div. 2) B. Little Robber Girl's Zoo 水题

    B. Little Robber Girl's Zoo 题目连接: http://www.codeforces.com/contest/686/problem/B Description Little ...

随机推荐

  1. C# 基本算法

    1.冒泡排序 排序 ,,,,,, }; ; i < ArrayList.Count(); i++) { for (int j = i; j < ArrayList.Count(); j++ ...

  2. 用JQuery的Ajax对表进行处理的一些小笔记

    --示例INSERT INTO 表名 ( 参数 )VALUES(@+参数),new SqlParameter("@参数", 值);注:配合SqlHelper使用. 一.Load() ...

  3. 省市区县镇级联数据JS版

    前言:网站开发经常会涉及到报名,报名通常就会有地区级联的要求.如下所示.做这个功能就必须要有数据支撑.昨天努力了一天,从网上鼓捣了一份数据.分享下.纯技术性分享,非盈利的.如果有侵权的地方请知会,马上 ...

  4. autorelease的对象何时被释放

    autorelease的对象何时被释放 参考答案: 如果了解一点点Run Loop的知道,应该了解到:Run Loop在每个事件循环结束后会去自动释放池将所有自动释放对象的引用计数减一,若引用计数变成 ...

  5. 【基础知识】.Net基础加强10天

    一. 复习 1. 委托是类型,还是一种引用类型. 2. 使用委托的时候必须new一个委托对象.即便看到代码中没有new委托对象,编译器也会在编译的时候帮我们new赋值给委托的方法,其实是存储在委托对象 ...

  6. Dynamic CRM 2013学习笔记(二十五)JS调用web service 实现多条记录复制(克隆)功能

    前面介绍过如何克隆一条当前的记录: Dynamic CRM 2013学习笔记(十四)复制/克隆记录 , 主要是通过界面上加一个字段,单击form上的clone 按钮时,改变这个字段的值以触发插件来实现 ...

  7. 【Leetcode】【Hard】Merge Intervals

    Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,1 ...

  8. google hack 之 查询语法

    google hack 之 查询语法 文/玄魂   前言 谷歌网页搜索技术,大部分在百度等搜索引擎中也适用.同样,这些搜索技术是来源于传统数据库检索技术,因而,对这部分的学习,能为后续章节的数据库检索 ...

  9. 微软BI 之SSIS 系列 - 2008 版本中变量 Int64 无法保存 bigint 类型数据的BUG

    开篇介绍 这是今天在帮别人看一个 2008R2 版本的项目时发现的一个 Bug,这个 Bug 在 SQL SERVER 2012 有的版本中可能已经解决,但在论坛上看到有的仍然存在. 在 SQL SE ...

  10. VR介绍

    VR(Virtual Reality,即虚拟现实,简称VR),是由美国VPL公司创建人拉尼尔在20世纪80年代初提出的.其具体内涵是:综合利用计算机图形系统和各种现实及控制等接口设备,在计算机上生成的 ...