微信开发中 ACCESS TOKEN 过期失效的解决方案详解
676
2022-08-25
K-th Nya Number (数位dp+二分)
Arcueid likes nya number very much. A nya number is the number which has exactly X fours and Y sevens(If X=2 and Y=3 , 172441277 and 47770142 are nya numbers.But 14777 is not a nya number ,because it has only 1 four). Now, Arcueid wants to know the K-th nya number which is greater than P and not greater than Q.
Input The first line contains a positive integer T (T<=100), indicates there are T test cases.
The second line contains 4 non-negative integers: P,Q,X and Y separated by spaces.
( 0<=X+Y<=20 , 0< P<=Q <2^63)
The third line contains an integer N(1<=N<=100).
Then here comes N queries.
Each of them contains an integer K_i (0 Output
For each test case, display its case number and then print N lines. For each query, output a line contains an integer number, representing the K_i-th nya number in (P,Q]. If there is no such number,please output "Nya!"(without the quotes). Sample Input 1 38 400 1 1 10 1 2 3 4 5 6 7 8 9 10 Sample Output Case #1: 47 74 147 174 247 274 347 374 Nya! Nya! 题目大概: 给定p,q,x,y,找出在p和q之间的 含有x个4和y个7的数中 第k大个数。 思路: 这个题和昨天做的一道题,类似,都是最简单的数位dp基础上加上二分就好了。 数位dp部分就不说了,谁都会。 在p和q之间二分,利用查找出来的符合条件的数量减去q的符合条件的数量就是第n大的数,利用二分找出第k大个数,就好了,也是基础二分。 主要是精度控制。 代码: #include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~