当前位置:网站首页>Digital DP example
Digital DP example
2022-06-13 11:02:00 【I can screw the bottle cap when I am born again】
empty
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int get(vector<int> num,int l,int r)
{
int res = 0;
for (int i=l;i>=r;i--) res = res*10 +num[i];
return res;
}
int power10(int u)
{
int res =1;
while (u--) res*=10;
return res;
}
int count (int n,int x)
{
if (!n) return 0;
vector<int> num;
while (n)
{
num.push_back(n%10);
n/=10;
}
n = num.size();
int res = 0;
for (int i=n-1-!x;i>=0;i--)
{
if (i<n-1)
{
res += get(num,n-1,i+1)*power10(i);
if (!x) res-=power10(i);
}
if (x==num[i]) res+=get (num,i-1,0)+1;
else if (x<num[i]) res+=power10(i);
}
return res;
}
int main(){
int a,b;
while (cin>>a>>b,a)
{
if (a>b) swap(a,b);
for (int i=0;i<=9;i++)
cout<< count(b,i)-count(a-1,i)<<' ';
cout<<endl;
}
return 0;
}
边栏推荐
- 容斥原理(能被整除的数)
- 宝塔中navicat连接mysql
- 判定二分图和二分图最大匹配
- C file package and download
- Go needs to add an arrow syntax, which is more like PHP!
- 元宇宙土地:是什么让数字房地产变得有价值
- 我们用了一个周末,将 370 万行代码迁移到了 TypeScript
- Alibaba's employees decreased by 4000 in the first quarter; Programmers wrote scripts to hang up vaccine numbers and were arrested for making a profit of 400000 yuan; Sohu encounters epic email fraud,
- 2022 coal mine water exploration and drainage special operation certificate examination question bank simulated examination platform operation
- Implementation of singleton mode
猜你喜欢
硬件工程师薪资虚高,你认可吗?
为发泄对上司不满,百度95后程序员删库被判9个月
Spark source code (I) how spark submit submits jars and configuration parameters to spark server
状态压缩DP例题(旅行商问题和填矩形问题)
Ue5 random point in bounding boxf from stream
数据库学习笔记(第十六章)
Brief description of redo logs and undo logs in MySQL
Understand an article: Spark operation mode
Inclusion exclusion principle (number divisible)
Euler function and finding Euler function by linear sieve
随机推荐
什么是400G以太网?
2022甘肃省安全员C证上岗证题目及在线模拟考试
判定二分图和二分图最大匹配
Electrolytic capacitor, tantalum capacitor, ordinary capacitor
The first laravel workflow engine released the official version of v1.0
C# 文件打包下载
Multithreading starts from the lockless queue of UE4 (thread safe)
统计特殊子序列数目(0,1,2)DP
MySQL transaction isolation level and mvcc
音视频技术开发周刊 | 249
About instruction set bits and instruction architecture bits
数据库学习笔记(第十五章)
2022 coal mine water exploration and drainage special operation certificate examination question bank simulated examination platform operation
Codeforces Round #798 (Div. 2)ABCD
Nim游戏阶梯 Nim游戏和SG函数应用(集合游戏)
元宇宙土地:是什么让数字房地产变得有价值
Ue5 random point in bounding boxf from stream
of_find_compatible_node查找出所有的节点
Idea remote debugging jar submitted by spark submit
2022煤矿探放水特种作业证考试题库模拟考试平台操作