Rank the number of shards

Source: Internet
Author: User

/* Number of shards in the row:
Tom is staring at the number 203879 in a daze.
Originally, 203879*203879 = 41566646641
What's amazing about this? Observe carefully that 203879 is a six-digit number, and the numbers on each digit are different, and all the digits after the square do not appear to constitute its own number.
There is another 6-digit feature. Please find it!
Next, we will summarize the filtering requirements:
1. 6-digit positive integer
2. The numbers on each digit are different.
3. Each digit of the number of shards does not include any integral digits of the original number.
The answer is a 6-digit positive integer.
Submit the answer in a browser.
Note: Only the other six digits are submitted. do not submit the information already given in the question. */
[Cpp]
# Include "stdio. h"
# Include "stdlib. h"
# Include "time. h"
Int xiangtong (int a [], int k)
{For (int c1 = 0; c1 <k; c1 ++)
For (int c2 = 0; c2 <k; c2 ++)
If (c1! = C2 & a [c1] = a [c2])
Return 1; // indicates the same
Return 0; // different
}
Int main ()
{Long kk; // Save the result after Square
Long int start, finish;
Start = clock ();
For (long int I = 102345; I <987654; I ++) // The long type cannot be used here, and an error will occur.
{Int a [6], B [12], k = 0, k1 = 0; // each bit in I is saved.
Long temp = I;
While (temp> 0)
{A [k ++] = temp % 10;
Temp = temp/10;
} // The low position of a's storage quantity, and the high position of a's storage quantity
If (! Xiangtong (a, k ))
{Kk = I * I;
While (kk> 0)
{B [k1 ++] = kk % 10;
Kk = kk/10 ;}
Int key = 0; // The value ranges from 1 to 0.
For (int c1 = 0; c1 <6; c1 ++)
For (int c2 = 0; c2 <k1; c2 ++)
If (a [c1] = B [c2]) {key = 1; break ;}
If (! Key)
{Printf ("% lld ^ 2 = % lld \ n", I, I * I );}
} // End if
} // End
Finish = clock ();
Printf ("\ nall time is: % lfs", (finish-start)/1000.0 );
Printf ("\ n ");
System ("pause ");
}

# Include "stdio. h"
# Include "stdlib. h"
# Include "time. h"
Int xiangtong (int a [], int k)
{For (int c1 = 0; c1 <k; c1 ++)
For (int c2 = 0; c2 <k; c2 ++)
If (c1! = C2 & a [c1] = a [c2])
Return 1; // indicates the same
Return 0; // different
}
Int main ()
{Long kk; // Save the result after Square
Long int start, finish;
Start = clock ();
For (long int I = 102345; I <987654; I ++) // The long type cannot be used here, and an error will occur.
{Int a [6], B [12], k = 0, k1 = 0; // each bit in I is saved.
Long temp = I;
While (temp> 0)
{A [k ++] = temp % 10;
Temp = temp/10;
} // The low position of a's storage quantity, and the high position of a's storage quantity
If (! Xiangtong (a, k ))
{Kk = I * I;
While (kk> 0)
{B [k1 ++] = kk % 10;
Kk = kk/10 ;}
Int key = 0; // The value ranges from 1 to 0.
For (int c1 = 0; c1 <6; c1 ++)
For (int c2 = 0; c2 <k1; c2 ++)
If (a [c1] = B [c2]) {key = 1; break ;}
If (! Key)
{Printf ("% lld ^ 2 = % lld \ n", I, I * I );}
} // End if
} // End
Finish = clock ();
Printf ("\ nall time is: % lfs", (finish-start)/1000.0 );
Printf ("\ n ");
System ("pause ");
}

 


 

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.