# xiaoxin juju needs help

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 861    Accepted Submission(s): 243

Problem Description

As we all known, xiaoxin is a brilliant coder. He knew **palindromic** strings when he was only a six grade student at elementry school.

This summer he was working at Tencent as an intern. One day his leader came to ask xiaoxin for help. His leader gave him a string and he wanted xiaoxin to generate palindromic strings for him. Once xiaoxin generates a different palindromic string, his leader
will give him a watermelon candy. The problem is how many candies xiaoxin‘s leader needs to buy?

Input

This problem has multi test cases. First line contains a single integer T(T≤20) which
represents the number of test cases.

For each test case, there is a single line containing a string S(1≤length(S)≤1,000).

Output

For each test case, print an integer which is the number of watermelon candies xiaoxin‘s leader needs to buy after mod 1,000,000,007.

Sample Input

```3
aa
aabb
a
```

Sample Output

```1
2
1
```

Source

BestCoder Round #77 (div.2)

```xiaoxin巨从小就喜欢字符串，六年级的时候他就知道了什么是回文串。这时，xiaoxin巨说到：如果一个字符串 SS 是回文串，那么该字符串从前往后看和从后往前看是一样一样的。

1.len = strlen(str),len>>=1;

2.num[i]：表示的是字符串每个字符 -  ‘a‘ 的个数，然后将其除以2；

My Code:

```#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long LL;
const int MOD = 1e9+7;
const int MAXN = 1e3+5;
char str[MAXN];
int num[28];
LL a[28];
void Ex_gcd(LL a, LL b, LL &x, LL &y)
{
if(b == 0)
{
x = 1;
y = 0;
return;
}
LL x1, y1;
Ex_gcd(b, a%b, x1, y1);
x = y1;
y = x1-(a/b)*y1;
}
int main()
{
int T;
cin>>T;
while(T--)
{
cin>>str;
int len = strlen(str);
memset(num, 0, sizeof(num));
for(int i=0; i<len; i++)
num[str[i]-'a']++;
int sum = 0;
for(int i=0; i<26; i++)
if(num[i]%2)
sum++;
if(sum >= 2)
puts("0");
else
{
LL ret = 1;
len>>=1;
for(int i=0; i<26; i++)
{
LL x, y;
num[i]>>=1;
a[i] = 1;
for(int j=1; j<=num[i]; j++)
a[i] = a[i]*j%MOD;
Ex_gcd(a[i], MOD, x, y);
x = (x%MOD+MOD)%MOD;
a[i] = x;
}
for(int i=1; i<=len; i++)
ret = ret*i%MOD;
for(int i=0; i<26; i++)
ret = ret*a[i]%MOD;
printf("%lld\n",ret%MOD);
}
}
return 0;
}
```

## hdu 5171 GTY&#39;s birthday gift (BestCoder Round #29)

GTY's birthday gift                                                                       Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 209    Accepted Submission(s): 71 Problem Description F

## BestCoder Round #69 (div.2) Baby Ming and Weight lifting（hdu 5610）

Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 681    Accepted Submission(s): 280 Problem Description Baby Ming is fond of weight lifting. He has a barbell pole(the

## hdu5418 BestCoder Round #52 (div.2) Victor and World （ floyd+状压dp）

Problem Description After trying hard for many years, Victor has finally received a pilot license. To have a celebration, he intends to buy himself an airplane and fly around the world. There are n countries on the earth, which are numbered from 1 to

## BestCoder Round #11 (Div. 2) 题解

HDOJ5054 Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 302    Accepted Submission(s): 229 Problem Description Bob and Alice got separated in the Square, they agreed that if they