I(cd1682)

#include<stdio.h>
#include<string.h>

int main()
{
	int i,j,k;
	int n;
	int t;
	char go[10000];
	scanf("%d",&t);
	while (t--)
	{
		scanf("%s",go);
		n=strlen(go);
		int ans=1;
		for (i=1;i<n;i++)
		{
			for (j=0;j<n;j++)
			{
				if (go[j]!=go[(i+j)%n])
					break;
			}
			if (j==n)
				ans++;
		}
		printf("%d\n",ans);
	}
}

I

Time Limit: 1000 ms Memory Limit: 65536 kB Solved: 109 Tried: 171

Description

Given a string A with length N.

A0 A1 A2 A3 ...... AN-1

S(0) = A0 A1 A2 A3 ...... AN-2 AN-1
S(1) = A1 A2 A3 ...... AN-2 AN-1 A0
S(2) = A2 A3 ...... AN-2 AN-1 A0 A1

......

S(N-1) = AN-1 A0 A1 A2 A3 ...... AN-2

Windy want to know how many i in [0, N - 1] that make S(i) euqal to S(0).
Can you find it for Windy?

Input

The first line of input is the number of test case.
For each test case,
there is only one line contains a string A.
String A only contains lowercase letter ('a'--'z').
1 <= N <= 1000

Output

For each test case output the answer on a single line.

Simple Input

3
aaa
abab
aba

Simple Output

3
2
1

Source




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值