Division Game

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description
There are k

piles of stones in a circle, numbered from 0

to k−1

, where the number of the stones in each pile is n

initially. You can do some round operations, where the initial round is numbered as the 1

-st round.

The operation of the i

-th round is to modify the pile of stones numbered (i−1)modk

. In each round, you should remove from this pile some stones (at least one stone), satisfying that the number of stones in this pile before this operation is a multiple of the number of stones in this pile after operation, which means that you ought to remain at least one stone in this pile.

The game is ended if there exists at least one pile containing only one stone. Given two positive integers n

and k

, your task is to calculate for each pile the number of the possible operation plans that it is the last operated pile before the game is ended.

The integer n

may be very large, so the prime-factor decomposition of n

will be given, in other words, if n=∏mi=1peii

, then the integers m

and (pi,ei)

(1≤i≤m)

will be given, but the integer n

will not.

The answer may be very large, so you only need to give the value of the answer modulo 985661441

.

 
Input
The input contains multiple test cases.

For each test case:

The first line contains two positive integers m

and k

, satisfying that 1≤m,k≤10

.

In next m

lines, the i

-th line contains two positive integers pi

and ei

, satisfying that 2≤pi≤109,

ei≥1,

mi=1ei≤105

.

It is guaranteed that p1,p2,⋯,pm

are distinct.

About 200

test cases in total, where no more than 5

cases satisfy ∑mi=1ei≥104

.

 
Output
For each test case, output "Case #x

: y0

y1

yk−1

" in one line (without quotes), where x

indicates the case number starting from 1

and yi

(0≤i<k)

denotes the number of the possible operation plans modulo 985661441

for the pile numbered i

of corresponding case.

 
Sample Input
1 1
2 2
2 1
3 1
5 1
1 2
2 3
2 2
2 4
5 4
 
Sample Output
Case #1: 2
Case #2: 3
Case #3: 6 4
Case #4: 1499980 1281085

HDU 多校1.4的更多相关文章

  1. 2018 HDU多校第四场赛后补题

    2018 HDU多校第四场赛后补题 自己学校出的毒瘤场..吃枣药丸 hdu中的题号是6332 - 6343. K. Expression in Memories 题意: 判断一个简化版的算术表达式是否 ...

  2. 2018 HDU多校第三场赛后补题

    2018 HDU多校第三场赛后补题 从易到难来写吧,其中题意有些直接摘了Claris的,数据范围是就不标了. 如果需要可以去hdu题库里找.题号是6319 - 6331. L. Visual Cube ...

  3. 2015 HDU 多校联赛 5363 Key Set

    2015 HDU 多校联赛 5363 Key Set 题目: http://acm.hdu.edu.cn/showproblem.php? pid=5363 依据前面给出的样例,得出求解公式 fn = ...

  4. 2015 HDU 多校联赛 5317 RGCDQ 筛法求解

    2015 HDU 多校联赛 5317 RGCDQ 筛法求解 题目  http://acm.hdu.edu.cn/showproblem.php? pid=5317 本题的数据量非常大,測试样例多.数据 ...

  5. [HDU多校]Ridiculous Netizens

    [HDU多校]Ridiculous Netizens 点分治 分成两个部分:对某一点P,连通块经过P或不经过P. 经过P采用树形依赖背包 不经过P的部分递归计算 树型依赖背包 v点必须由其父亲u点转移 ...

  6. 【杂题总汇】HDU多校赛第十场 Videos

    [HDU2018多校赛第十场]Videos 最后一场比赛也结束了…… +HDU传送门+ ◇ 题目 <简要翻译> 有n个人以及m部电影,每个人都有一个快乐值.每场电影都有它的开始.结束时间和 ...

  7. hdu多校1002 Balanced Sequence

    Balanced Sequence Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s) ...

  8. HDU多校(Distinct Values)

    Problem Description Chiaki has an array of n positive integers. You are told some facts about the ar ...

  9. hdu多校6

    这个场要恶心死我了.. 1001 积分题,不要四舍五入 //#pragma comment(linker, "/stack:200000000") //#pragma GCC op ...

  10. hdu 多校第一场

    1001 思路:打表可以发现只有3|n 和 4|n 的情况有解,判一下就好啦. #include<bits/stdc++.h> #define LL long long #define f ...

随机推荐

  1. BZOJ1093 [ZJOI2007]最大半连通子图 【tarjan缩点 + DAG最长路计数】

    题目 一个有向图G=(V,E)称为半连通的(Semi-Connected),如果满足:?u,v∈V,满足u→v或v→u,即对于图中任意 两点u,v,存在一条u到v的有向路径或者从v到u的有向路径.若G ...

  2. 洛谷 P4168 [Violet]蒲公英 解题报告

    P4168 [Violet]蒲公英 题目背景 亲爱的哥哥: 你在那个城市里面过得好吗? 我在家里面最近很开心呢.昨天晚上奶奶给我讲了那个叫「绝望」的大坏蛋的故事的说!它把人们的房子和田地搞坏,还有好多 ...

  3. 如何开始创建第一个基于Spring MVC的Controller

    万事开头难,良好的开端是成功的一半! 以下示例怎么开始创建我们的第一个Spring MVC控制器Controller 1.新建一个java类,命名为:MyFirstController,包含以下代码, ...

  4. The XOR Largest Pair [Trie]

    描述 在给定的N个整数A1,A2--AN中选出两个进行xor运算,得到的结果最大是多少? 输入格式 第一行一个整数N,第二行N个整数A1-AN. 输出格式 一个整数表示答案. 样例输入 3 1 2 3 ...

  5. [codechef MEXDIV]Mex division

    题目链接:https://vjudge.net/contest/171650#problem/I 直接用set+dp水过去了... /* 设dp[i]表示前i个做划分满足条件的方案数 有一个显然的转移 ...

  6. Codeforces Round #526 (Div. 2) E. The Fair Nut and Strings

    E. The Fair Nut and Strings 题目链接:https://codeforces.com/contest/1084/problem/E 题意: 输入n,k,k代表一共有长度为n的 ...

  7. xiaoluo同志Linux学习之CentOS6.4

    小罗同志写的不错,弄个列表过来啊   Linux学习之CentOS(三十六)--FTP服务原理及vsfptd的安装.配置 xiaoluo501395377 2013-06-09 01:04 阅读:56 ...

  8. 【BZOJ4657】tower [网络流]

    炮塔 Time Limit: 10 Sec  Memory Limit: 256 MB Description Input Output 一行一个整数表示答案. Sample Input 4 5 0 ...

  9. CF502C The Phone Number

    C. The Phone Number time limit per test 1 second memory limit per test 256 megabytes     Mrs. Smith ...

  10. thinkphp 导入微信小程序加密解密库

    第三方类库 第三方类库指除了 ThinkPHP 框架.应用项目类库之外的其他类库,一般由第三方系统或产品提供,如 Smarty.Zend 等系统的类库等. 前面使用自动加载或 import 方法导入的 ...