https://ac.nowcoder.com/acm/contest/59007
A
假设数字n有len位
则小len的长度,每个都有九个方案。
长度和len一样的,至少有n[0]-1种方案
n[0]n[0]n[0]...的这个方案暴力地跑一遍看看是不是小于等于n即可
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<bits/stdc++.h> using namespace std; typedef long long ll; int read() { int x;scanf("%d",&x);return x; } char s[1000]; int len,ans; int main() { // freopen("1.in","r",stdin); scanf("%s",s+1); len=strlen(s+1); ans=len*9-9; ans++; for(int i=2;i<=len;i++) if(s[i]<s[1]) { ans--; break; } ans+=s[1]-'1'; cout<<ans; }A
B
标签:12,int,题解,len,ACM,ans From: https://www.cnblogs.com/qywyt/p/17435916.html