HDU 3555 Bomb
生活随笔
收集整理的這篇文章主要介紹了
HDU 3555 Bomb
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
模板題
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll num; int a[20],len; ll dp[2][20],ten[20]; ll dfs(int pos,bool pre,bool lim) {int Max=lim?a[pos]:9;if(pos==1)return Max==9&⪯if(!lim&&dp[pre][pos]!=-1)return dp[pre][pos];ll ret=0;for(int i=0;i<=Max;++i){//printf("%d:%d ",pos,i);if(i==9&&pre)ret+=lim?(num%ten[pos-1]+1):ten[pos-1];else ret+=dfs(pos-1,i==4,lim&&i==Max);//printf("%d\n",ret);}if(!lim)dp[pre][pos]=ret;return ret; } ll solve(ll x) {len=0;while(x){a[++len]=x%10;x/=10;}return dfs(len,0,1);//todo } int main() {//freopen("Input.txt","r",stdin);ten[0]=1;for(int i=1;i<=19;++i)ten[i]=ten[i-1]*10;memset(dp,-1,sizeof dp);int t;scanf("%d",&t);while(t--){scanf("%I64d",&num);printf("%I64d\n",solve(num));} }轉載于:https://www.cnblogs.com/maoruimas/p/9714590.html
總結
以上是生活随笔為你收集整理的HDU 3555 Bomb的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 个人项目对方代码分析(随机生成不同难度试
- 下一篇: 用贝叶斯定理解决三门问题并用Python