Problem 3027 --11 Dimensions

3027: 11 Dimensions

"
Time Limit $8$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $1$ 正确数量 $1$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
11 Dimensions is a cute contestant being talented in math. One day, 11 Dimensions came across a problem but didn't manage to solve it. Today you are taking training here, so 11 Dimensions turns to you for help. 

You are given a decimal integer SS with nn bits s1s2…sn(0≤si≤9)s1s2…sn(0≤si≤9), but some bits can not be recognized now(replaced by ``??''). The only thing you know is that SS is a multiple of a given integer mm

There may be many possible values of the original SS, please write a program to find the kk-th smallest value among them. Note that you need to answer qq queries efficiently.
The first line of the input contains an integer T(1≤T≤10000)T(1≤T≤10000), denoting the number of test cases. 

In each test case, there are three integers n,m,q(1≤n≤50000,2≤m≤20,1≤q≤100000)n,m,q(1≤n≤50000,2≤m≤20,1≤q≤100000) in the first line, denoting the length of SS, the parameter mm, and the number of queries. 

In the second line, there is a string ss of length nn, denoting the given decimal integer SS. It is guaranteed that sisi is either an integer within [0,9][0,9] or ``??'', and s1s1 is always an integer within [1,9][1,9]

For the next qq lines, each line contains an integer ki(1≤ki≤1018)ki(1≤ki≤1018), denoting each query. 

It is guaranteed that ∑n≤500000∑n≤500000 and ∑q≤106∑q≤106.
For each query, print a single line containing an integer, denoting the value of SS. If the answer exists, print Smod(109+7)Smod(109+7) instead, otherwise print ``-1-1''.
1
5 5 5
2??3?
1
2
3
100
10000
20030
20035
20130
24935
-1

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

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$6716 $ms] 淡意的温柔 590729 2020-06-05 09:16:38
内存最少[$0 $KB] 淡意的温柔 590729 2020-06-05 09:16:38
第一AC 淡意的温柔 590729 2020-06-05 09:16:38
第一挑战 淡意的温柔 590729 2020-06-05 09:16:38

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

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