当前位置:网站首页>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,需要特判一下.
代码:
边栏推荐
- 制品库是什么?
- Drive IT Modernization with Low Code
- Redis常用命令
- 你有一份斗破苍穹词库,请查收
- Go 事,Gopher 要学的数字类型,变量,常量,运算符 ,第2篇
- jlink and swd interface definition
- Threshold-based filtering buffer management scheme in a shared buffer packet switch core part of the paper
- SMIC CIM localization project suspended?Rising software: not shut down, changed to remote development!
- 用低代码驱动IT现代化
- 搜索--09
猜你喜欢
嘉为蓝鲸荣获工信部“数字技术融合创新应用解决方案”
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
太香了!自从用了这款接口神器,我的团队效率提升了 60%!
LeetCode50天刷题计划(Day 18—— 搜索旋转排序数组(8.50-12.00)
The 6th "Blue Hat Cup" National College Student Network Security Skills Competition Semi-Final Part WriteUp
gpu-admission 源码分析
技术人必看!数据治理是什么?它对数据中台建设重要吗?
Flutter气泡框实现
Does your child lack self-discipline?Ape Counseling: Pay attention to "blank" in the schedule to give children more control
你有一份斗破苍穹词库,请查收
随机推荐
浮动及其特点
正则表达式常用示例
Analysis of the name matching process between the LCD driver and the device (Tiny4412)
皕杰报表在传参乱码
mpf6_Time Series Data_quandl_更正kernel PCA_AIC_BIC_trend_log_return_seasonal_decompose_sARIMAx_ADFull
你是怎么知道数据库 Htap 能力强弱的?怎么能看出来
面试美团被问到了Redis,搞懂这几个问题,让你轻松吊打面试官
LeetCode 19. Delete the Nth last node of the linked list
LeetCode 21. Merge two ordered linked lists
leetcode 823. Binary Trees With Factors(因子二叉树)
LT8911EXB MIPI CSI/DSI转EDP信号转换
LeetCode 445. 两数相加 II
LeetCode50天刷题计划(Day 19—— 在排序数组中查找元素的第一个和最后一个位置(9.10-10.40)
Diary 16
LeetCode50天刷题计划(Day 18—— 搜索旋转排序数组(8.50-12.00)
可视化服务编排在金融APP中的实践
dedecms supports one-click import of Word content
Network Fundamentals (Section 1)
Microchip launched a high-performance 77GHz millimeter-wave radar chip, and has received tens of thousands of orders before mass production
第5章 虚拟存储器