Title: Square Number of rows
Xiao Ming is looking at the number 203879 in a daze.
Originally, 203879 * 203879 = 41566646641
What's so magical about that? Carefully observed, 203879 is a 6-digit number, and its number on each digit is different, and it does not appear on all digits after the square to make its own number.
There is a 6-digit number with this feature, please find it!
Let's summarize the screening requirements:
1.6-bit positive integer
2. The numbers on each digit are different
3. Each digit of its square number does not contain any constituent digits of the original number
The answer is a 6-bit positive integer.
Please submit your answer via the browser.
Note: Submit only the other 16 digits that have been given in the question.
Note: Do not write anything else (e.g., descriptive text).
Brute Force enumeration:
#include <iostream> #include <cstring>using namespace Std;int vis[10];int judge (long long int i) {while ( i) { if (vis[i%10]==0) vis[i%10]++; else return 0; i/=10; } return 1;} int Judge1 (Long long int i) { while (i) { if (vis[i%10]!=0) return 0; i/=10; } return 1;} int main () { long long int i; for (i=123456;i<=987654;i++) { memset (vis,0,sizeof (Vis)); if (!judge (i)) continue; if (!judge1 (i*i)) continue; cout<<i<<endl; } return 0;}
Blue Bridge Cup-exclusive square number