|Online Judge||Problem Set||Authors||Online Contests||User|
A Number from Yanghui Triangle
Yanghui Triangle, as known as Pascal’s Triangle, is a number triangle with numbers arranged in staggered row such that
Consider a decimal number p with sequentially consists of k-digit decimal representations of the numbers in the n-th row of Yanghui Triangle where log10 an, r < k for all 0 ≤ r ≤ n. Here are some examples:
The numerical value of p can be very large. Your task is to calculate p mod m for some integer m.
The input consists of T test cases. The number of test cases T is given in the first line of the input file. Each test case consists of one line containing n, k, m (0 ≤ n ≤ 1 000 000, 1 ≤ k ≤ 1 000 000, 2 ≤ m ≤ 109) in order.
The output should contain p mod m, one per line.
3 0 2 7 2 2 12345 5 2 1000000
1 10201 100501
Use faster I/O to deal with the large-size input.
POJ Monthly--2006.09.29, Kim, Chan Min (kcm1700@POJ)
[Submit] [Go Back] [Status] [Discuss]
Home Page Go Back To top
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator