当前位置:网站首页>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;
}边栏推荐
猜你喜欢
![[geek challenge 2019] rce me 1](/img/66/e135f7e5a7cbdeb5b697f3939a3402.png)
[geek challenge 2019] rce me 1

倍福通过CTU和TON实现时间片大小和数量的控制

倍福PLC实现绝对值编码器原点断电保持---bias的使用

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

倍福TwinCAT通过Emergency Scan快速检测物理连接和EtherCAT网络

Record a phpcms9.6.3 vulnerability to use the getshell to the intranet domain control
Summary of wechat applet test points

Don't mess with full_ Case and parallel_ CASE

First knowledge - Software Testing

Machine learning notes - seasonality of time series
随机推荐
Sinotech software outsourcing
C structure: definition and example
Biff TwinCAT can quickly detect the physical connection and EtherCAT network through emergency scan
8、【STM32】定时器(TIM)——中断、PWM、输入捕获实验(一文精通定时器)
G - Cow Bowling
Copy multiple Excel files and name them different
倍福通过CTU和TON实现时间片大小和数量的控制
Unit practice experiment 8 - using cmstudio to design microprogram instructions based on basic model machine (1)
I - Dollar Dayz
P2393 yyy loves Maths II
外观模式(Facade)
Don't mess with full_ Case and parallel_ CASE
Learning Processing Zoog
First pass! Baidu AI Cloud Xiling platform has obtained the authoritative certification of digital human ability evaluation from the Institute of information technology
2、并行接口、协议和相关芯片介绍(8080、8060)
首批通过!百度智能云曦灵平台获信通院数字人能力评测权威认证
Go structure method
偶言佳句,孤芳自赏
What are the common categories of software testing?
Basic principle and application routine of Beifu PLC rotary cutting