hdu 6143 Killer Names (2017多校第八场)
来源:互联网 发布:zigbee协议栈编程 编辑:程序博客网 时间:2024/06/16 03:53
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6143
Killer Names
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 147 Accepted Submission(s): 75
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 exactlyn 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.
>
> 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
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 (T≤10 ), denoting the number of test cases.
Each test case contains two integersn and m (1≤n,m≤2000 ).
Each test case contains two integers
Output
For each test case, output one line containing the maximum number of clones Vader can create.
Output the answer mod 109+7
Output the answer
Sample Input
23 22 3
Sample Output
2 18
Source
2017 Multi-University Training Contest - Team 8
Recommend
liuyiding | We have carefully selected several similar problems for you: 6143 6142 6141 6140 6139
解析:求dp[n][i] * dp[n][j] % p * f[m][i+j] % p的和, 其中dp[i][j] = dp[i-1][j-1] + dp[i-1][j]*j ; dp[i][j]就是在i个位置放置j个不同的字母,已经有序了,如果前i-1个位置放置j-1个字母,在第i个位置只能是字母j,即dp[i-1][j-1],如果前i-1个位置放置j个字母,在第i个位置可以放置j中不同的字母。f[i][j]是A(i, j),一个排列
代码:
#include<bits/stdc++.h>using namespace std;typedef long long LL;const int N = 3009;const LL p = 1e9+7ll;LL f[N][N], dp[N][N];void init(){ for(int i = 1; i <= 2000; i++) { f[i][0] = 1ll; for(int j = 1; j <= i; j++) f[i][j] = f[i][j-1] * (i - j + 1ll) % p; } dp[0][0] = 1ll; for(int i = 1; i <= 2000; i++) { for(int j = 1; j <= i; j++) dp[i][j] = (dp[i-1][j-1] + dp[i-1][j]*j) % p; }}int main(){ init(); int t, m, n; scanf("%d", &t); while(t--) { scanf("%d%d", &n, &m); LL ans = 0ll; for(int i = 1; i <= m; i++) { for(int j = 1; j + i <= m; j++) { ans += dp[n][i]*dp[n][j]%p*f[m][j+i]%p; } } printf("%lld\n", ans%p); } return 0;}
阅读全文
0 0
- hdu 6143 Killer Names (2017多校第八场)
- 2017 杭电多校赛第八场 1011题 Killer Names HDu 6143
- HDU 6143 Killer Names(组合数学 递推 17多校第八场)
- hdu6143 Killer Names 2017多校第八场1011 组合数学
- Killer Names(hdu 6143)
- Killer Names(HDU 6143)
- HDU 6143 Killer Names
- hdu--6143--Killer Names
- hdu 6143 Killer Names
- hdu 6143 Killer Names
- HDU 6143 Killer Names
- hdu 6143 Killer Names
- HDU 6143 Killer Names
- HDU --6143 Killer Names
- HDU 6143 Killer Names (容斥)
- HDU 6143 Killer Names(dp 思维)
- HDU 6143 Killer Names(容斥)
- hdu 6143 Killer Names(第二类斯特林数)
- 实现自动登录和记住密码
- 幸会springMVC框架
- CTP Python API(利用Swig 封装)Windows版(traderapi)
- hdu6081--度度熊的王国战略(百度之星资格赛)
- SpringMVC @RequestBody问题:Unrecognized field , not marked as ignorable
- hdu 6143 Killer Names (2017多校第八场)
- 利用多线程和信号量,互斥量实现的经典的生产者与消费者模型
- 二分法查找
- android__shape 圆角矩形 圆环画法
- 单链表逆转、字符串按单词逆转
- Java 并发基础
- 实现一个clone函数并可以对js中的5种主要数据类型进行值复制
- 线段树基础与模板与简单应用
- Cow Acrobats