![]() | ||||
Online Judge | Problem Set | Authors | Online Contests | User |
---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
A Number from Yanghui Triangle
Description Yanghui Triangle, as known as Pascal¡¯s Triangle, is a number triangle with numbers arranged in staggered row such that an, 0 = 1 (n ¡Ý 0) 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. Input 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. Output The output should contain p mod m, one per line. Sample Input Sample Output Hint Source |
[Submit] [Go Back] [Status] [Discuss]
All Copyright Reserved 2003-2005 Ying Fuchen,Xu Pengcheng
Any problem, Please Contact Administrator