192384576
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "iostream" #include "sstream" #include "string" #include "queue" #include "algorithm" typedef long long LL; using namespace std; int Array[9] = { 1,2,3,4,5,6,7,8,9 }; long long val( int b) { long long x=0; for (int i = 0; i < b; i++) x = x * 10 + Array[i]; return x; } bool check() { stringstream t; t << val(9); string ss=t.str(); for (int i = 1; i < 9; i++) { string s2; int x = 1; long long x1 = val( i); while(s2.size()<9) { stringstream m; m<<x1*x++; s2 += m.str(); } //cout << ss << " " << s2 << endl; if (s2 == ss)return true; } return false; } int main() { do { if (check()) { for (int i = 0; i < 9; i++) { printf("%d", Array[i]); } printf("\n"); } } while (next_permutation(Array, Array + 9)); return 0; }