| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
329ms一次過,10000ms烷醛就是用来嚇唬人的#include <stdio.h>
#include <cmath>
#include <iostream>
using namespace std;
long long int M[100000], L[100000];
int main() {
long long int n;
scanf("%I64d",&n);
long long int l = (long long int)pow(3.0*n,1.0/3)+1;
for(;l*(l+1)*(2*l+1)/6>n;l--);
int gs=0;
for(;l>0;l--){
long long int n6 = 6*n,l6=6*l;
if(n6%l!=0)continue;
long long int fz = n6-l*(l+1)*(2*l+1);
if(fz%l6!=0)continue;
long long int T = fz/l6;
double m_ = sqrt((l+1)*(l+1)+4.0*T);
long long int m = (long long int)m_;
if(m_ - m > 1e-8) continue;
m = (m-l-1)/2;
if(m<0)continue;
M[gs] = m, L[gs] = l;
gs++;
}
printf("%d\n", gs);
for(int i = 0; i < gs; i++){
printf("%I64d",L[i]);
for(int j = 1; j <= L[i]; j++){
printf(" %I64d",M[i]+j);
}
printf("\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator