Simple Problem

TimeLimit:1000MS  MemoryLimit:256MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

Hang give you a function f(x).
If x < 10 f(x) = x.
If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);
And ai(0<=i<=9) can only be 0 or 1 .
Give you a0 ~a9,two integer k,m,outf(k)%m

Maybe you should use integer for 64 bits,please use %I64d

出题人英语四级没过,看不懂就下一题

Input

Mutiple test cases
In each case, there will be two lines.
In the first line , there are two positive integers k and m. ( k<2e9 , m<1e5 )
In the second line , there are ten integers a0 ~ a9.

Output
For each case, output f(k) % m in one line.
SampleInput
10 9999
1 1 1 1 1 1 1 1 1 1
20 500
1 0 1 0 1 0 1 0 1 0
SampleOutput
45
104
Submit
题目统计信息详细
总AC数25
通过人数21
尝试人数23
总提交量36
AC率58.33%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: