当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3012: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

an, 0 = 1 (n ≥ 0)
an, n = 1 (n ≥ 0)
an, r = an − 1, r − 1 + an − 1, r (0 < r < n)

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 ≤ rn. Here are some examples:

nkp
011
3201030301
52010510100501

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.

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3012

最后修改于 2020-10-29T06:50:06+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 131072