当前位置:网站首页>C. Add One--Divide by Zero 2021 and Codeforces Round #714 (Div. 2)
C. Add One--Divide by Zero 2021 and Codeforces Round #714 (Div. 2)
2022-06-23 16:58:00 【Qin Sanma】
Divide by Zero 2021 and Codeforces Round #714 (Div. 2)
C. Add One
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
You are given an integer nn. You have to apply mm operations to it.
In a single operation, you must replace every digit dd of the number with the decimal representation of integer d+1d+1. For example, 19121912 becomes 2102321023 after applying the operation once.
You have to find the length of nn after applying mm operations. Since the answer can be very large, print it modulo 109+7109+7.
Input
The first line contains a single integer tt (1≤t≤2⋅1051≤t≤2⋅105) — the number of test cases.
The only line of each test case contains two integers nn (1≤n≤1091≤n≤109) and mm (1≤m≤2⋅1051≤m≤2⋅105) — the initial number and the number of operations.
Output
For each test case output the length of the resulting number modulo 109+7109+7.
Example
input
Copy
5 1912 1 5 6 999 1 88 2 12 100
output
Copy
5 2 6 4 2115
Note
For the first test, 19121912 becomes 2102321023 after 11 operation which is of length 55.
For the second test, 55 becomes 2121 after 66 operations which is of length 22.
For the third test, 999999 becomes 101010101010 after 11 operation which is of length 66.
For the fourth test, 8888 becomes 10101010 after 22 operations which is of length 44.
=========================================================================
For each number, the effect of a fixed number of operations is also fixed , So we can preprocess every digital operation m Length of times . dp[i][j] For operation i Time ,j The length obtained by numbers , General 0-8, operation i The length obtained at a time is j+1, operation i-1 Length obtained for times , And for 9 Come on , yes i-1 Time , get 0,1 The sum of the lengths .
# include<iostream>
# define mod 1000000007
using namespace std;
typedef long long int ll;
ll dp[200000+10][10];
int main ()
{
for(int i=0;i<=9;i++)
{
dp[0][i]=1;
}
for(int i=1;i<=200000;i++)
{
for(int j=0;j<9;j++)
{
dp[i][j]=dp[i-1][j+1];
}
dp[i][9]=(dp[i-1][0]+dp[i-1][1])%mod;
}
int t;
cin>>t;
while(t--)
{
ll n,m;
scanf("%lld%lld",&n,&m);
while(n)
{
ans=(ans+dp[m][n%10])%mod;
n/=10;
}
cout<<ans<<'\n';
}
return 0;
}
边栏推荐
- Block, non block, multiplexing, synchronous, asynchronous, bio, NiO, AIO
- 官方零基础入门 Jetpack Compose 的中文课程来啦
- JSON in MySQL_ Extract function description
- How long does it take to open a stock account by mobile phone? Is online account opening safe?
- 华为手机通过adb安装APK提示“签名不一致,该应用可能已被修改”
- Case analysis of camera power supply disturbed, seriously affecting image quality
- leetcode:30. Concatenate substrings of all words [counter matching + pruning]
- TQ of R language using tidyquant package_ The transmute function calculates the daily, monthly and weekly returns of a stock. Ggplot2 uses the bar plot to visualize the monthly return data of the stoc
- Right leg drive circuit principle? ECG acquisition is a must, with simulation files!
- How to select an oscilloscope? These 10 points must be considered!
猜你喜欢

2022 Jiufeng primary school (Optics Valley No. 21 primary school) student source survey

【解决】npm WARN config global `--global`, `--local` are deprecated. Use `--location=global`

Focus: zk-snark Technology

The Google play academy team PK competition is in full swing!

The official Chinese course of zero foundation introduction jetpack compose is coming

Asemi ultrafast recovery diode es1j parameters, es1j package, es1j specification

Online communication - the combination of machine learning and knowledge reasoning in trusted machine learning (Qing Yuan talk, issue 20, Li Bo)

Comparison of asemi Schottky diode and ultrafast recovery diode in switching power supply

leetcode:30. 串联所有单词的子串【Counter匹配 + 剪枝】

Why do we say that the data service API is the standard configuration of the data midrange?
随机推荐
使用Jmeter进行性能测试及性能监控平台搭建
What does websocket do?
ELK日志收集系统部署
Network remote access raspberry pie (VNC viewer)
炒股买股票需要怎么选择呢?安全性不错的?
What are the risks of opening a fund account? Is it safe to open an account
JMeter stress testing tutorial
如何选择示波器?这10点一定要考虑!
leetcode:30. Concatenate substrings of all words [counter matching + pruning]
Thinking analysis of binary search method
Openresty Foundation
Another breakthrough! Alibaba cloud enters the Gartner cloud AI developer service Challenger quadrant
ADC digital DGND, analog agnd mystery!
ABAP essays - program optimization notes
What is an abstract class? How to define abstract classes?
R语言使用colorblinr包模拟色盲视觉、将已有的ggplot2可视化结果图像使用edit_colors函数编辑转化为色盲视觉友好的可视化结果、并自定设置色盲形式、色盲严重级别
读书郎通过上市聆讯:平板业务毛利率走低,2021年利润同比下滑11%
Tupu digital twin 3D wind farm, offshore wind power of smart wind power
Block, non block, multiplexing, synchronous, asynchronous, bio, NiO, AIO
面渣逆袭:MySQL六十六问!建议收藏