#include <iostream>
#include <sstream>
using namespace std;
int main()
{
int nMax = 0;
for ( int number = 1; number < 10000; ++number )
{
int digit[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int count = 0;
bool valid = true;
for ( int times = 1; valid && count < 9; ++times )
{
int x = number * times;
while ( x != 0 )
{
int remaider = x % 10;
if ( remaider == 0 || digit[remaider] != 0 )
{
valid = false;
}
digit[remaider] = 1;
++count;
x /= 10;
}
}
if ( valid )
{
stringstream ss;
for ( int times = 1; ss.str().length() < 9; ++times )
{
ss << number * times;
}
int concatenation = 0;
ss >> concatenation;
if ( concatenation > nMax )
{
nMax = concatenation;
}
}
}
cout << nMax << endl;
return 0;
}
http://projecteuler.net/problem=38 [Answer:932718654]
最新推荐文章于 2023-11-15 12:12:51 发布