从98765到01234,至多枚举97531,对于每个数枚举0~9出现的次数,共10次,总数量大概为975310,完全可以通过
#include <bits/stdc++.h>
using namespace std;
int k;
int cnt[10]{};
bool check()
{
for(auto&x:cnt)
if(x>=2)return false;
return true;
}
int main() {
scanf("%d",&k);
for(int i = 98765;i>=1234;--i)
{
memset(cnt,0,sizeof cnt);
cnt[i%10]++;
cnt[i/10%10]++;
cnt[i/100%10]++;
cnt[i/1000%10]++;
cnt[i/10000%10]++;
if(check())
{
--k;
if(k==0)
{
printf("%05d\n",i);
break;
}
}
}
return 0;
}

京公网安备 11010502036488号