Problem 3001 --Good Numbers

3001: Good Numbers

"
Time Limit $3$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Let’s consider a number N is good if and only if the occurrence of each digit is multiple of 3 in the octonal representation of N. 
You are good at math, so we want to ask you to calculate how many good numbers with K digits in octonal representation, which are multiple of P. This number may be huge, so you are only to print it modulo 10^9 + 9. 
Note that good numbers should be positive and should not have any leading zeroes. 
For example, suppose K = 3 and P = 2, good numbers are 222(8), 444(8) and 666(8). 111(8) is not good because it is not the multiple of 2. 102(8) is not good because 1 occurs once, not multiple of 3.
There are multiple (at most 100) test cases. Please process until EOF (end of file).
Each test case contains 2 integers K (1 <= K <= 10^18, K is divisible by 3), P (<8).
At most 15 test cases are big. (K > 1000).
For each test case, print a single integer denoting the answer in one line.
3 1
3 2
7
3

推荐代码 查看3001 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 2019 Multi-University Training Contest 4 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛