Blue Bridge Cup-exclusive square number

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.