Invoker
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 122768/62768 K (Java/Others)
Total Submission(s): 515Accepted Submission(s): 163
Problem Description
On of Vance's favourite hero is Invoker, Kael. As many people knows Kael can control the elements and combine them to invoke a powerful skill. Vance like Kael very much so he changes the map to make Kael more powerful.
In his new map, Kael can control n kind of elements and he can put m elements equal-spacedly on a magic ring and combine them to invoke a new skill. But if a arrangement can change into another by rotate the magic ring or reverse the ring along the axis, they
will invoke the same skill. Now give you n and m how many different skill can Kael invoke? As the number maybe too large, just output the answer mod 1000000007.
Input
The first line contains a single positive integer T( T <= 500 ), indicates the number of test cases.
For each test case: give you two positive integers n and m. ( 1 <= n, m <= 10000 )
Output
For each test case: output the case number as shown and then output the answer mod 1000000007 in a line. Look sample for more information.
Sample Input
Sample Output
Case #1: 21
Case #2: 1
Hint
For Case #1: we assume a,b,c are the 3 kinds of elements.
Here are the 21 different arrangements to invoke the skills
/ aaaa / aaab / aaac / aabb / aabc / aacc / abab /
/ abac / abbb / abbc / abcb / abcc / acac / acbc /
/ accc / bbbb / bbbc / bbcc / bcbc / bccc / cccc /
Source
这个题是一个很裸露的波利亚定理的运用
但是最后取余要用逆元。
但是这个题比较巧妙,因为mod=1000000007,他是一个质数,于是要求某一个数的逆元的话直接mod-2次方,然后二分幂去模就行了
至于波利亚定理,我同样使用的POJ 2154以及POJ 2409的写法
我的代码:
分享到:
相关推荐
收集的部分HDOJ杭电ACM题的代码 大牛勿下 全是基础供初级acmer使用
2017hdu多校联合训练第一场标程及数据
ACM/ICPC 2010年多校联合第十场第九题的解题报告及代码,AC代码有三个,最好的是src
HDU2013暑期多校联合训练第一场0723-解题报告和标程
这份压缩包内包含了2019年杭电多校第一场的数据与标程,欢迎下载
2014 Multi-University Training Contest 1多校联合赛标程和部分数据。
hdoj 2013 多校训练3标程+解题报告
自己积累的部分杭电oj的(hdu)解题代码。。大家有空来看看。 基本上是自己写的哈。有错误之处请指教、
杭电oj4405,一道简单的概率dp题目
杭电acm解题报告 详细解析2000-2099 适合acm初学者
ACM ICPC HDOJ1000
2019 Multi-University Training Contest 4(2019hdu多校第五场数据与标程),欢迎大家下载
HDOJ,2011阿里巴巴程序设计公开赛的标程 题目位置:http://acm.hdu.edu.cn/vip/2011alibaba/index.php
2019 Multi-University Training Contest 4(2019hdu多校第六场数据与标程)
杭州电子科技大学hdoj1002,大整数相加问题
此乃2012多校联赛第五场的题目+数据+题解+标程
hdu 期末考试复习资料 计算机网络 编译原理 计算机图形学 编译原理 信息安全与技术 数据库应用系统开发
hdu 1695 GCD(欧拉函数+容斥原理).docx
HDU的1250,主要是利用高精度加法,但是代码有点繁琐,效率不是很高
华为HLR相关资料,介绍了HLR中的HDU数据库单元原理