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. 安徽师大附中%你赛day4T2 演讲解题报告

    演讲 题目背景: 众所周知,\(\mathrm{Zdrcl}\)是一名天天\(\mathrm{AK}\)的高水平选手. 作为一民长者,为了向大家讲述自己\(\mathrm{AK}\)的经验,他决定在一 ...

  2. HZOI String STL的正确用法

                                                                      String          3s 512 MB描述硬盘中里面有n ...

  3. Planning your upgrade with Upgrade Advisor

    Planning your upgrade with Upgrade Advisor You should use the Upgrade Advisor tool (if it is availab ...

  4. jw player学习笔记三---发布到其它网站

    一.通过官网发布向导 登陆 http://www.longtailvideo.com,注册一个账号,进入你的用户管理中心,如下图 然后按提示,一步步操作,就会得到js代码了. 二.自己服务器发布 &l ...

  5. Asp.Net Core 基于QuartzNet任务管理系统(这是一篇用来水的随笔)

    之前一直想搞个后台任务管理系统,零零散散的搞到现在,也算完成了. 废话不多说,进入正题. github地址:https://github.com/YANGKANG01/QuartzNetJob 一.项 ...

  6. 有关getClassLoader().getResourceAsStream(fileName)、class.getResourceAsStream(fileName)和().getContextClassLoader().getResourceAsStream(fileName)的区别

    一:前言 在自己获取属性时,碰见了XX.class.getResourceAsStream(fileName),自己对这个其实不是很理解,上网查了下资料,又看到了上述的几个,所以就研究了下. 二:内容 ...

  7. HTTP中的URL长度限制

    首先,其实http 1.1 协议中对url的长度是不受限制的,协议原文: The HTTP protocol does not place any a priori limit on the leng ...

  8. 线段树+矩阵快速幂 Codeforces Round #373 (Div. 2) E

    http://codeforces.com/contest/719/problem/E 题目大意:给你一串数组a,a[i]表示第i个斐波那契数列,有如下操作 ①对[l,r]区间+一个val ②求出[l ...

  9. [BZOJ2946] [Poi2000]公共串解题报告|后缀数组

    给出几个由小写字母构成的单词,求它们最长的公共子串的长度. 单词个数<=5,每个单词长度<=2000     尽管最近在学的是SAM...但是看到这个题还是忍不住想写SA... (其实是不 ...

  10. 【洛谷 P4168】[Violet]蒲公英(分块)

    题目链接 题目大意:给定\(n\)个数和\(m\)个求区间众数的询问,强制在线 这题我\(debug\)了整整一个下午啊..-_- 从14:30~16:45终于\(debug\)出来了,\(debug ...