题解
2024-09-16 19:03:36
发布于:广东
0阅读
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;
}
这里空空如也
有帮助,赞一个