当前位置:网站首页>HDU 3555 Bomb
HDU 3555 Bomb
2022-06-26 13:12:00 【YJEthan】
Here's a number n, I want you to ask 0-n How many numbers in contain 49, use n- Not included 49 The number of is the answer .
#include<bits\stdc++.h>
using namespace std;
typedef long long ll;
ll dp[20][10];// Recorded in the i position , The first one is j The number of qualified
int a[20];//
ll dfs(ll pos,ll pre,ll lim)// The current position , The first digit , Whether the previous digit is the maximum number of the previous digit
{
if(pos==-1) return 1;// At this point, all locations have been enumerated , Meet the requirements ;
if(!lim&&dp[pos][pre]!=-1)
return dp[pos][pre];
int up=lim?a[pos]:9;//up Represents the maximum number that can be enumerated
ll ans=0;
for(int i=0;i<=up;i++)
{
if(pre==4&&i==9)
continue;
ans+=dfs(pos-1,i,lim&&i==up);// If the current position has not reached the maximum number , Then there is no limit on the number of the next digit .
}
if(!lim) dp[pos][pre]=ans;// Save the number of qualified current states
return ans;
}
ll solve(ll n)
{
int i=0;
while(n)
{
a[i++]=n%10;
n/=10;
}
return dfs(i-1,0,1);
}
int main()
{
int t;
scanf("%d",&t);
memset(dp,-1,sizeof(dp));
while(t--)
{
ll n;
scanf("%I64d",&n);
printf("%I64d\n",n-solve(n)+1);
}
return 0;
}边栏推荐
- 倍福PLC基于NT_Shutdown实现控制器自动关机重启
- 复制多个excel然后命名不同的名字
- HDU1724[辛普森公式求积分]Ellipse
- Mode pont
- QT .pri 的建立与使用
- H - Sumsets POJ 2229
- Electron official docs series: Testing And Debugging
- How does easygbs solve the abnormal use of intercom function?
- Angle de calcul POSTGIS
- Chapter 01_ Installation and use of MySQL under Linux
猜你喜欢

scrapy——爬取漫画自定义存储路径下载到本地

Mode pont

首批通过!百度智能云曦灵平台获信通院数字人能力评测权威认证

Beifu PLC passes MC_ Readparameter read configuration parameters of NC axis

Script - crawl the customized storage path of the cartoon and download it to the local

OPLG: 新一代云原生可观测最佳实践

P2393 yyy loves Maths II

May product upgrade observation station

Processing polyhedron change

P5733 【深基6.例1】自动修正
随机推荐
Summary of wechat applet test points
HDU 5860
倍福PLC基于CX5130实现数据的断电保持
mariadb学习笔记
B - Bridging signals
[geek challenge 2019] rce me 1
8、【STM32】定时器(TIM)——中断、PWM、输入捕获实验(一文精通定时器)
Deep parsing MySQL binlog
Verilog中的系统任务(显示/打印类)--$display, $write,$strobe,$monitor
C - Common Subsequence
[BSidesCF 2019]Kookie 1
Basic principle and application routine of Beifu PLC rotary cutting
HDU 3555 Bomb
D - skiing
Use the script to crawl the beautiful sentences of the sentence fan website and store them locally (blessed are those who like to excerpt!)
Electron official docs series: Development
组合模式(Composite )
详细讲解C语言10(C语言系列)
IDC report: the AI cloud market share of Baidu AI Cloud ranks first for six consecutive times
Goto statement to realize shutdown applet