这题主要看观察能力
他要找最大的。
就得比题目给的那个要大
给的是9开头的。
所以呢。要找的肯定也是9开头的。
首先看90几行不,乘1乘2乘3后发现位数不能到9位
再看900多
再看9000多
发现9000多有可能行
乘以2后是5位数
然后凑一块就是个9位数
然后枚举9000多就行了
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <cmath>
#include <map>
#include <ctime>
#define MAXN 111111
#define INF 100000007
using namespace std;
int v[11];
bool isok()
{
if(v[0]) return 0;
for(int i = 1; i <= 9; i++)
if(v[i] != 1) return 0;
return 1;
}
int main()
{
for(int i = 9876; i >= 9123; i--)
{
memset(v, 0, sizeof(v));
int ti = i;
while(ti)
{
v[ti % 10]++;
ti /= 10;
}
ti = i * 2;
while(ti)
{
v[ti % 10]++;
ti /= 10;
}
if(isok())
{
printf("%d%d\n", i, i * 2);
break;
}
}
return 0;
}