Beijing 2008
1000ms 0K
描述:
As we all know, the next Olympic Games will be held in Beijing in 2008. So the year 2008 seems a little special somehow. You are looking forward to it, too, aren't you? Unfortunately there still are months to go. Take it easy. Luckily you meet me. I have a problem for you to solve. Enjoy your time.
Now given a positive integer N, get the sum S of all positive integer divisors of 2008N. Oh no, the result may be much larger than you can think. But it is OK to determine the rest of the division of S by K. The result is kept as M.
Pay attention! M is not the answer we want. If you can get 2008M, that will be wonderful. If it is larger than K, leave it modulo K to the output. See the example for N = 1,K = 10000: The positive integer divisors of 20081 are 1、2、4、8、251、502、1004、2008,S = 3780, M = 3780, 2008M % K = 5776.
输入:
The input consists of several test cases. Each test case contains a line with two integers N and K (1 ≤ N ≤ 10000000, 500 ≤ K ≤ 10000). N = K = 0 ends the input file and should not be processed.
输出:
For each test case, in a separate line, please output the result.
北京2008
描述:
我们知道下一届奥运会将在2008年的北京举行。所以2008这个年份似乎有点不同。你也期待它不是吗?不幸的是还要等几个月。放轻松,幸运的是你遇到了我。我有一个问题等你来解决。玩得开心。
现在给你一个正整数N,得到所有2008的N次方的约数的和S。哦不,这个结果可能比你想的要大。但是可以算出S除以K的余数。这个结果被保存为M。
请注意!M不是我们要的结果。如果你可以得到2008的M次方,那就完美了。如果它比K要大,留下它对K的模来输出。来看这个例子,N=1,K=10000:这个2008的正整数约数有1、2、4、8、251、502、1004、2008,S=3780,M=3780,2008的M次方%K=5776。
输入:
输入包括多组数据。每组数据包括一行两个证书N和K(1 ≤ N ≤ 10000000, 500 ≤ K ≤ 10000)。N=K=0结束输入并且不应该被处理。
输出:
对于每组数据,请在独立的一行输出结果。