xiaoxin juju needs help

本文概述了AI音视频处理领域的关键技术,包括视频分割、语义识别、自动驾驶、AR、SLAM等,并探讨了其在实际应用中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

xiaoxin juju needs help

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 380    Accepted Submission(s): 111

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)


第一次做BC爆零了鄙视


代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    long long C[502][502];
    for (int i=0;i<502;i++)
    C[i][0]=1;
    for (int i=1;i<502;i++)
    for (int j=1;j<=i;j++)
        C[i][j]=(C[i-1][j-1]+C[i-1][j])%1000000007;
    int t;scanf("%d",&t);
    char ch[1050];
    int shu[28],p;
    while (t--)
    {
        scanf("%s",ch);
        int leght=strlen(ch);
        memset(shu,0,sizeof(shu));
        for (int i=0;i<leght;i++)
        {
            p=ch[i]-'a';
            shu[p]++;
        }
        int ge=0,wei;
        for (int i=0;i<26;i++)
        { 
            if (shu[i]%2==1)
            {
                wei=i;
                shu[i]--;
                ge++;
            } 
        }
        ge=ge-(leght%2);
        if (ge)
        {
            printf("0\n");
            continue;//这里用continue,,,,用break;wrong几次。/。。。。。 
        }
        for (int i=0;i<26;i++)
        shu[i]/=2;
        long long s=1;
        int kk=leght/2;
            for (int i=0;i<26;i++)
            {
                s=(s*C[kk][shu[i]])%1000000007;
                kk-=shu[i];
            }
        printf("%I64d\n",s);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值