码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 多校1.4

时间:2017-07-25 13:27:44      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:ssi   lines   round   output   tle   hat   circle   class   oss   

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 k1技术分享 , 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 (i1)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=技术分享m技术分享i=1技术分享p技术分享e技术分享i技术分享技术分享i技术分享技术分享 , then the integers m技术分享 and (p技术分享i技术分享,e技术分享i技术分享)技术分享 (1im)技术分享 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 1m,k10技术分享 .

In next m技术分享 lines, the i技术分享 -th line contains two positive integers p技术分享i技术分享技术分享 and e技术分享i技术分享技术分享 , satisfying that 2p技术分享i技术分享10技术分享9技术分享,技术分享 e技术分享i技术分享1,技术分享 技术分享m技术分享i=1技术分享e技术分享i技术分享10技术分享5技术分享技术分享 .

It is guaranteed that p技术分享1技术分享,p技术分享2技术分享,?,p技术分享m技术分享技术分享 are distinct.

About 200技术分享 test cases in total, where no more than 5技术分享 cases satisfy 技术分享m技术分享i=1技术分享e技术分享i技术分享10技术分享4技术分享技术分享 .
 

 

Output
For each test case, output "Case #x技术分享 : y技术分享0技术分享技术分享 y技术分享1技术分享技术分享 ?技术分享 y技术分享k1技术分享技术分享 " in one line (without quotes), where x技术分享 indicates the case number starting from 1技术分享 and y技术分享i技术分享技术分享 (0i<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

标签:ssi   lines   round   output   tle   hat   circle   class   oss   

原文地址:http://www.cnblogs.com/Roni-i/p/7233427.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!