当前位置:网站首页>(digital statistics dp+good) acwing 338 Counting problem
(digital statistics dp+good) acwing 338 Counting problem
2022-06-11 23:35:00 【Age worry】
338. Counting problem
Topic link https://www.acwing.com/problem/content/340/
subject :

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int get_ct(int u){
int ct=0;
while(u){
ct++;
u/=10;
}
return ct;
}
int get(int u,int id){
int ct=get_ct(u);
int res=0;
for(int j=1;j<=ct;j++){
int k=pow(10,j-1);
int r=u%k;
int l=u/k/10;
int temp=u/k%10;
if(id) res+=l*k;
if(!id&&l) res+=(l-1)*k;
if(id==temp&&(id||l))
res+=r+1;
if(id<temp&&(id||l))
res+=k;
}
return res;
}
int main(){
int a,b;
while(cin>>a>>b){
if(!a&&!b) break;
if(a>b) swap(a,b);
for(int i=0;i<10;i++){
printf("%d ",get(b,i)-get(a-1,i));
}
printf("\n");
}
return 0;
}
边栏推荐
- PHP mkdir(): Permission denied上传文件会把文件夹权限改为411权限
- sonarqube介紹和安裝步驟
- 抗原产品进入家庭,中国医疗器械企业迎来新蓝海
- C collection of questions for project review
- [day13-14 intensive literature reading] cross dimensional magnetic interactions arise from memory interference
- What are the pitfalls of redis's current network: using a cache and paying for disk failures?
- Wechat applet Bluetooth development
- Antigen products enter the family, and Chinese medical device enterprises usher in a new blue ocean
- 2022 safety officer-a certificate test question simulation test platform operation
- PHP mkdir(): permission denied uploading a file will change the folder permission to 411 permission
猜你喜欢

Lake Shore—SuperTran-VP 连续流低温恒温器系统

【Day1/5 文献精读】Speed Constancy or Only Slowness: What Drives the Kappa Effect

Are you still struggling with the gold content of PMP

2022年低压电工上岗证题目及在线模拟考试

I2C read / write process
![[naturallanguageprocessing] [multimodal] albef: visual language representation learning based on momentum distillation](/img/b7/0ccd11bd97aa0e217775b31fff3511.jpg)
[naturallanguageprocessing] [multimodal] albef: visual language representation learning based on momentum distillation

How to make scripts executable anywhere

Introduction to Solr Basics

2022安全员-C证判断题模拟考试平台操作

2022 safety officer-b certificate theoretical question bank and simulation test
随机推荐
ETF operation record: March 1, 2022
删除收货地址【项目 商城】
Single page pull-down refresh and double page pull-down refresh of MUI
JS to add an attribute to an array object
mysql——find_in_set用法
一文读懂Logstash原理
loading
Lake shore vnf series low temperature thermostat system - sample in flowing steam
Software installation and use, etc
Wireless communication comparison of si4463, si4438 and Si4432 schemes of wireless data transmission module
Research Report on development trend and competitive strategy of global customized power supply industry
CD process
The latest "capsule Network Overview" paper of imperial technology, etc., 29 pages of PDF, expounds the concept, method and application of capsule
Vs code writing assembly code [microcomputer principle]
New Year Countdown JS case
How to construct PostgreSQL error codes
Mysql5 and mysql8 are installed at the same time
通用树形结构的迭代与组合模式实现方案
sonarqube介绍和安装步骤
[day1/5 literature intensive reading] speed constancy or only slowness: what drives the kappa effect