2-1-1812: Perfect Cubic

Source: Internet
Author: User

1812: Perfect Cube
    • View
    • Submit
    • Statistics
    • Questions
Total time limit:
1000ms
Memory Limit:
65536kB
Describe

The equation shaped like a3= B3 + C3 + D3 is called the perfect cubic equation. For example 123 = 63 + 83 + 103. Write a program on any given positive integer N (n≤100), looking for all four tuples (A, B, C, D), so that a3 = b3 + C3 + D3, where a,b,c,d is greater than 1, less than or equal to N, and b& Lt;=c<=d.

Input
a positive integer N (n≤100).
Output
each row outputs a perfect cubic. The output format is:
Cube = A, Triple = (b,c,d)
Where the a,b,c,d location is used to find the actual four-tuple value into.

Please follow the value of a, from small to large output. When the value of a in the two perfect cubic equation is the same, the first output with small B value, the same as the priority output with a small C value, and the same as a small D value.
Sample input
24
Sample output
Cube = 6, Triple = (3,4,5) cube =, Triple = (6,8,10) cube =, Triple = (2,12,16) cube =, Triple = (9,12,15) cube = 19, Triple = (3,10,18) cube =, Triple = (7,14,17) cube =, Triple = (12,16,20)
1#include <stdio.h>2 intMain ()3 {4     intn,a,b,c,d;5scanf"%d",&n);6      for(a=5; a<=n;a++)7     {8          for(b=2; b<=a-2; b++)9         {Ten              for(c=b;c<=a-1; C + +) One             { A                  for(d=c;d<=a;d++) -                 { -                     if(a*a*a==b*b*b+c*c*c+d*d*d) theprintf"Cube =%d, Triple = (%d,%d,%d) \ n", a,b,c,d); -                 } -             } -         } +     } -     return 0; +}

2-1-1812: Perfect Cubic

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.