Graveyard Design
Time limit:10000ms Memory limit:64000k
Total submissions:7687 accepted:1913
Case Time limit:2000ms Description
King George has recently decided, that he would, and a new design 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 s2 graves. 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
Input file contains n-the number of graves to is located in the graveyard (1 <= n <= 1014). Output
The first line of the output file print k-the number of possible graveyard designs. Next k lines must contain the descriptions of the graveyards. Each line must start with l-the number of sections in the corresponding graveyard, followed by L integers-the lengths of section sides (successive positive integer numbers). Output Line's in descending order of L. Sample Input
2030 Sample Output
2
4 21 22) 23 24
3 Source
Northeastern Europe 2004, Northern subregion
Test instructions: give you an n, range explode int in 1,22,32 ... 1,2^2,3^2 ... in the sequence, you ask for a number of sequential sequences to make it n, and all are listed
Analysis: The first one to see the bare ruler take, directly with a pair to save the left and right end, on the line, Up hit a 1e7 square table, direct enumeration, and then feel no problem of the turn, who knows the MLE, then the brain into the body, put down, eat rice just remember why to play table, directly enumerate the square is OK, remember to open a long long on the line reference code
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <map>
#include <cmath>
#include <vector>
#define LL Long long
#define FI first
#define SE second< c8/>using namespace std;
int main () {
ll n;cin>>n;
int ans = 0;
Vector<pair<int,int> >p;
int L, R;ll t = 0;
L = R = 1;
while (true) {
while (T < n && 1ll*r*r <= N) {T + = 1ll*r*r;r++;}
if (t = = N) p.push_back (Make_pair (l,r));
if (t < n) break;
T-= 1ll*l*l;
l++;
}
Cout<<p.size () <<endl;
for (int i = 0;i < P.size (); i++) {
printf ("%d", p[i].se-p[i].fi);
for (int j = P[i].fi;j < p[i].se;j++) {
printf ("%d", j);
} cout<<endl;
}
return 0;
}
If you have any errors or omissions, please talk to up,thx in private.