当前位置:网站首页>CodeForces - 628D (digital dp)
CodeForces - 628D (digital dp)
2022-08-10 12:16:00 【51CTO】
Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the number on even positions and nowhere else.
For example, the numbers 1727374, 17, 1 are 7-magic but 77, 7, 123, 34, 71 are not 7-magic. On the other hand the number 7 is 0-magic, 123 is 2-magic, 34 is 4-magicand 71 is 1-magic.
Find the number of d-magic numbers in the segment [a, b] that are multiple of m. Because the answer can be very huge you should only find its value modulo 109 + 7 (so you should find the remainder after dividing by 109 + 7).
Input
The first line contains two integers m, d (1 ≤ m ≤ 2000, 0 ≤ d ≤ 9) — the parameters from the problem statement.
The second line contains positive integer a in decimal presentation (without leading zeroes).
The third line contains positive integer b in decimal presentation (without leading zeroes).
It is guaranteed that a ≤ b, the number of digits in a and b are the same and don't exceed 2000.
Output
Print the only integer a — the remainder after dividing by 109 + 7 of the number of d-magic numbers in segment [a, b] that are multiple of m.
Examples
Input
2 6 10 99
Output
8
Input
2 0 1 9
Output
4
Input
19 7 1000 9999
Output
6
题目大意:
Find the number of a certain number in an interval,需要是m的倍数,And odd digits cannot be includedd,Even numbers are requiredd.The number of digits is2000位.
思路:
首先是数位dp.
关于m的限制,Just calculate the edge modulo directly.d限制,Need to discuss parity.
The number of digits is large,Strings are required,这样的话,闭区间,The number on the left minus one is not easy to calculate,需要特判一下.
代码:
边栏推荐
- Excel function formulas - LOOKUP function
- 10 个 Reduce 常用“奇技淫巧”
- 22年BATJ大厂必问面试题(复盘):JVM+微服务+多线程+锁+高并发
- How to join We Media, learn about these 5 monetization modes, and make your account quickly monetize
- Threshold-based filtering buffer management scheme in a shared buffer packet switch core part of the paper
- LeetCode 92. 反转链表 II
- Ssm framework construction process [easy to understand]
- 中芯CIM国产化项目暂停?上扬软件:未停摆,改为远程开发!
- 堪称神级的阿里巴巴“高并发”教程——基础+实战+源码+面试+架构 全包了
- LeetCode 19. Delete the Nth last node of the linked list
猜你喜欢

The 6th "Blue Hat Cup" National College Student Network Security Skills Competition Semi-Final Part WriteUp

面试美团被问到了Redis,搞懂这几个问题,让你轻松吊打面试官

Can CLIP also do segmentation tasks?The University of Göttingen proposed a model CLIPSeg that uses text and image prompts to perform three segmentation tasks at the same time, draining CLIP capabiliti

如何让别人看不懂你的 JS 代码?把你当大佬!

皕杰报表在传参乱码

Go 事,Gopher 要学的数字类型,变量,常量,运算符 ,第2篇

three.js模糊玻璃效果

dedecms支持Word内容一键导入

OPNsense安装配置Zenarmor

If someone asks you about distributed transactions again, throw this to him
随机推荐
Flutter气泡框实现
If someone asks you about distributed transactions again, throw this to him
嘉为蓝鲸荣获工信部“数字技术融合创新应用解决方案”
日记16
gpu-admission 源码分析
dedecms支持Word内容一键导入
皕杰报表在传参乱码
22年BATJ大厂必问面试题(复盘):JVM+微服务+多线程+锁+高并发
three.js模糊玻璃效果
Excel function formulas - HLOOKUP function
三星计划2023年开始在越南生产半导体零部件
Database management tool: dynamic read-write separation
IDC第一的背后,阿里云在打造怎样的一朵“视频云”?
codevs 2370 小机房的树 (LCA)
LeetCode50天刷题计划(Day 17—— 下一个序列(14.50-16.30)
Clicking Exercise - 64 Longest Harmonic Subsequences
Licking Exercise - 63 Find all anagrams in a string
迈矽科推出高性能77GHz毫米波雷达芯片,尚未量产就已获数万颗订单
HDU 6040 Hints of sd0061 (技巧)
第六届”蓝帽杯“全国大学生网络安全技能大赛半决赛部分WriteUp