当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

Brief description of redo logs and undo logs in MySQL

Mysql database conceptual design using E-R model
![[elm classification] data classification based on particle swarm optimization convolution neural network CNN combined with limit learning machine elm with matlab code](/img/e3/a299393e865104d96341ce3d93ac6b.png)
[elm classification] data classification based on particle swarm optimization convolution neural network CNN combined with limit learning machine elm with matlab code

vivo大规模 Kubernetes 集群自动化运维实践

vivo大规模 Kubernetes 集群自动化运维实践

Go needs to add an arrow syntax, which is more like PHP!

恶意代码实战分析Lab05-01

Introduction to binary tree

Go 要加个箭头语法,这下更像 PHP 了!

Go zero microservice Practice Series (III. API definition and table structure design)
随机推荐
为发泄对上司不满,百度95后程序员删库被判9个月
2021CCPC网络赛题解加总结
Wechat applet customer service automatic reply - PHP implementation
Ubuntu安装mysql压缩包备查
Database learning notes (Chapter 15)
基于Vue+Nest.js+MySQL的跨平台开源社区运营管理系统
《自然-通讯》| 用机器学习和时间序列数据为气候变化下的武装冲突风险建模
Simple query cost estimation [Gauss is not a mathematician this time]
Chapter VI i/o management
Chapter VII document management
服务器的使用
Read pgstat [this time Gauss is not a mathematician]
Navicat connection MySQL in Pagoda
Redis相关
Easyclick run code snippet out null
Acwing game 55
WinForm resolves frequent refresh of black screen
DNS protocol analysis
Introduction to binary tree
Ubuntu installs MySQL compressed package for future reference