Swust OJ interesting three-digit (0319)

Source: Internet
Author: User

Interesting three-digit number (0319)Time limit (ms): 65535 submission:158 accepted:62 Description has such a set of numbers, each group consists of three three-bit numbers, and the three numbers 1~9 have and only once, What's more special is that in these three numbers, two smaller numbers are added equal to another number (such as 124 659 783). Your task is to find all the groups that meet the above criteria (appear in groups and in ascending order (between each group in ascending order of the first element). For one of these groups, three numbers are sorted in ascending order). Inputno input output outputs all groups that satisfy the test instructions (a space between three numbers per group). Sample Input
Sample Output124 659 783125 739 864| | |-------ellipsis | |216 738 954218 349 567| | | | | Hint source computer Science and Technology major 2008 program design contest
1#include <iostream>2#include <algorithm>3 using namespacestd;4 intMain ()5 {6     inta[9]={1,2,3,4,5,6,7,8,9},b,c,d;7      while(Next_permutation (a,a+9))8     {9b=a[0]* -+a[1]*Ten+a[2];Tenc=a[3]* -+a[4]*Ten+a[5]; Oned=a[6]* -+a[7]*Ten+a[8]; A         if(b+c==d&&b<=c) -         { -cout<<b<<' '<<c<<' '<<d<<Endl; the         } -     } - return 0; -}

Note: B>c break is not correct, 231 987 654 the next permutation 234 156 789 terminates the loop, which is obviously incorrect.

Swust OJ interesting three-digit (0319)

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.