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)