Hdu6143 Killer Names(2017多校第8场)

Killer Names

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


Problem Description
> Galen Marek, codenamed Starkiller, was a male Human apprentice of the Sith Lord Darth Vader. A powerful Force-user who lived during the era of the Galactic Empire, Marek originated from the Wookiee home planet of Kashyyyk as the sole offspring of two Jedi Knights—Mallie and Kento Marek—who deserted the Jedi Order during the Clone Wars. Following the death of his mother, the young Marek's father was killed in battle by Darth Vader. Though only a child, Marek possessed an exceptionally strong connection to the Force that the Dark Lord of the Sith sought to exploit.
>
> When Marek died in 2 BBY, shortly after the formation of the Alliance, Vader endeavored to recreate his disciple by utilizing the cloning technologies of the planet Kamino. The accelerated cloning process—an enhanced version of the Kaminoan method which allowed for a rapid growth rate within its subjects—was initially imperfect and many clones were too unstable to take Marek's place as the Dark Lord's new apprentice. After months of failure, one particular clone impressed Vader enough for him to hope that this version might become the first success. But as with the others, he inherited Marek's power and skills at the cost of receiving his emotions as well, a side effect of memory flashes used in the training process.
>
> — Wookieepedia

Darth Vader is finally able to stably clone the most powerful soilder in the galaxy: the Starkiller. It is the time of the final strike to destroy the Jedi remnants hidden in every corner of the galaxy.

However, as the clone army is growing, giving them names becomes a trouble. A clone of Starkiller will be given a two-word name, a first name and a last name. Both the first name and the last name have exactly  n  characters, while each character is chosen from an alphabet of size  m . It appears that there are  m2n  possible names to be used.

Though the clone process succeeded, the moods of Starkiller clones seem not quite stable. Once an unsatisfactory name is given, a clone will become unstable and will try to fight against his own master. A name is safe if and only if no character appears in both the first name and the last name.

Since no two clones can share a name, Darth Vader would like to know the maximum number of clones he is able to create.
 

Input
The First line of the input contains an integer  T  ( T10 ), denoting the number of test cases. 

Each test case contains two integers  n  and  m  ( 1n,m2000 ).
 

Output
For each test case, output one line containing the maximum number of clones Vader can create.

Output the answer   mod 109+7
 

Sample Input
  
  
2 3 2 2 3
 

Sample Output
  
  
2 18
 

Source

———————————————————————————————————
 题目的意思是用m个字母取构成两个长度为n的字符串,两个字符串不能有公共的字母,问最大可能种数
思路:先预处理出一个数组,存确定用i的字母取构成长度为n的字符串方案数,这个可以递推出来,然后取枚举前一个字符串取多少个,用组合数学搞一搞
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <unordered_map>
#include <functional>

using namespace std;

#define LL long long
const int INF=0x3f3f3f3f;

LL a[2005];
const LL mod=1e9+7;
LL mypow(LL x,LL y)
{
    LL ans=1;
    while(y>=1)
    {
        if(y&1)
            ans=(ans*x)%mod;
        x=(x*x)%mod;
        y>>=1;
    }
    return ans;
}

LL c[2022][2022];
void chs()
{
    c[0][0] = 1;
    for(int i = 1; i < 2022; i++)
    {
        c[i][0] = c[i][i] = 1;
        for(int j = 1; j < i; j++)
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
}

int main()
{
    int T;
    LL m,n;
    chs();
    for(scanf("%d",&T); T--;)
    {
        scanf("%lld%lld",&n,&m);
        for(int i=1; i<m; i++)
        {
            a[i]=mypow(i,n);
            for(int j=1; j<i; j++)
                a[i]=((a[i] - c[i][j]*a[j] % mod) % mod + mod) % mod;
        }
        LL ans = 0;
        for(int i=1; i<m; i++)
        {
            for(int j = 1; j <= m - i; j++)
                ans = (ans + c[m][i] * a[i] % mod * c[m - i][j] % mod * a[j] % mod) % mod;
        }
        printf("%lld\n", (ans % mod + mod) % mod);
    }
    return 0;
}



Vivado2023是一款集成开发环境软件,用于设计和验证FPGA(现场可编程门阵列)和可编程逻辑器件。对于使用Vivado2023的用户来说,license是必不可少的。 Vivado2023的license是一种许可证,用于授权用户合法使用该软件。许可证分为多种类型,包括评估许可证、开发许可证和节点许可证等。每种许可证都有不同的使用条件和功能。 评估许可证是免费提供的,让用户可以在一段时间内试用Vivado2023的全部功能。用户可以使用这个许可证来了解软件的性能和特点,对于初学者和小规模项目来说是一个很好的选择。但是,使用评估许可证的用户在使用期限过后需要购买正式的许可证才能继续使用软件。 开发许可证是付费的,可以永久使用Vivado2023的全部功能。这种许可证适用于需要长期使用Vivado2023进行开发的用户,通常是专业的FPGA设计师或工程师。购买开发许可证可以享受Vivado2023的技术支持和更新服务,确保软件始终保持最新的版本和功能。 节点许可证是用于多设备或分布式设计的许可证,可以在多个计算机上安装Vivado2023,并共享使用。节点许可证适用于大规模项目或需要多个处理节点进行设计的用户,可以提高工作效率和资源利用率。 总之,Vivado2023 license是用户在使用Vivado2023时必须考虑的问题。用户可以根据自己的需求选择合适的许可证类型,以便获取最佳的软件使用体验。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值