#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll count(ll n,ll x){//找1-n中x的个数,时间复杂度log(10,n)
ll cnt=0,k;
for (ll i = 1; k = n/i;i*=10){
ll high=k/10;
if(x==0){
if(high) high--;
else break;
}
cnt+=high*i;
ll cur=k%10;
if(cur>x) cnt+=i;
else if(cur==x) cnt+=n-k*i+1;
}
return cnt;
}
int main(){
return 0;
}
求1-n中x(0-9)的个数
猜你喜欢
转载自blog.csdn.net/lgz0921/article/details/99587416
今日推荐
周排行