当前位置:网站首页>数位DP例题
数位DP例题
2022-06-13 10:57:00 【重生之我会拧瓶盖】

空

#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;
}
边栏推荐
- IDEA远程调试spark-submit提交的jar
- 阿里一季度员工减少4000人;程序员写脚本抢挂疫苗号,牟利40万被刑拘;搜狐遭遇史诗级邮件诈骗,张朝阳回应 | Q资讯
- 21世纪以来的历次“粮食危机”,发生了什么?
- Chapter VI i/o management
- 数据库系统概念(第十七章)
- D generate unique ID at compile time
- Nature communications - modeling armed conflict risk under climate change using machine learning and time series data
- D evaluate twice map
- Solution to qt5.12 unable to input Chinese (unable to switch Chinese input method) in deepin system
- 2020 ICPC Asia Taiwan Online Programming Contest C Circles
猜你喜欢
随机推荐
vivo大规模 Kubernetes 集群自动化运维实践
21世纪以来的历次“粮食危机”,发生了什么?
【20220526】UE5.0.2 release d11782b
D evaluate twice map
2022 Gansu Province safety officer C certificate work certificate title and online simulation examination
Nature communications - modeling armed conflict risk under climate change using machine learning and time series data
SSM整合初步 所得细节
Full stack development practice | integrated development of SSM framework
flutter简单优秀的开源dialog使用free_dialog
WinForm resolves frequent refresh of black screen
winform 解决黑屏 频繁刷新
of_ find_ compatible_ Node find all nodes
第七章 文件管理作业
2022 coal mine water exploration and drainage special operation certificate examination question bank simulated examination platform operation
Software testing often asks, do you really build a testing environment?
Idea remote debugging jar submitted by spark submit
Go zero microservice Practice Series (III. API definition and table structure design)
宝塔访问从IP改为域名
Electrolytic capacitor, tantalum capacitor, ordinary capacitor
Vivo large scale kubernetes cluster automation operation and maintenance practice








