题解
2023-03-31 21:28:42
发布于:上海
146阅读
0回复
0点赞
#include<iostream>
using namespace std;
bool valid(long long n){
int a[10]={0,0,0,0,0,0,0,0,0,0};
if(n<10000000){
a[0]++;
}
for(;n>0;n/=10){
a[n%10]++;
if(a[n%10]>1){
return false;
}
}
return true;
}
int main(){
long long n;
int c=0;
cin>>n;
long long p = 9*8*7*6*5*4*3;
long long left = n/10000000;
c += left * p;
for(long long i=left * 10000000;i<=n;i++){
long long first, second, third;
first = i/10000000;
second = (i - first * 10000000)/1000000;
if(first == second) {
i += 999999;
continue;
}
if(!valid(i)){
continue;
}
c++;
}
cout<<c;
}
全部评论 1
烧毕
2023-11-18 来自 上海
0
有帮助,赞一个