POJ 2100 Graveyard Design (ruler)

Source: Internet
Author: User
Tags integer numbers

Description

New  for The Royal Graveyard. The graveyard must consist of several sections, each of which must is a square of graves. All sections must has different number of graves. After a consultation with he astrologer, King George decided that the lengths of sections sides must be a sequence of succ Essive positive integer numbers. A section with side length s contains s2graves. George have estimated the total number of graves that'll be located on the graveyard and now wants to know all possible g Raveyard designs satisfying the condition. You were asked to find them.

Input

 in the Graveyard (11014 ).

Output

 in the corresponding graveyard, followed by L integers---the lengths of sections sides (successive positive inte GER numbers). Output Line's indescending order of L.

Sample Input

2030

Sample Output

2 4  +  A  at  - 3  -  -  -

Source

Northeastern Europe 2004, Northern subregion ruler, see the code in detail
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <vector>5#include <algorithm>6 using namespacestd;7 #definell Long Long8vector< pair<ll,ll> >ans;9 Ten intMain () One { A ll N; -      while(SCANF ("%i64d", &n) = =1){ -ll s=1, t=1; thell sum=0; -          for(;;) { -  -              while(sum<N) { +sum=sum+t*T; -t++; +             } A             if((t1) * (t1) >N) at                  Break; -             if(sum==N) { -Ans.push_back (Make_pair (s,t-1)); -             } -sum-=s*s; -s++; in  -         } toll m=ans.size (); +printf"%i64d\n", m); -          for(intI=0; i<m;i++){ thell l=Ans[i].first; *ll r=Ans[i].second; $printf"%i64d", r-l+1);Panax Notoginseng              for(LL j=l;j<=r;j++){ -printf"%i64d", j); the             } +printf"\ n"); A  the         } +     } -     return 0; $}
View Code

POJ 2100 Graveyard Design (ruler)

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.