Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

329ms一次過,10000ms烷醛就是用来嚇唬人的

Posted by KatrineYang at 2016-11-07 10:11:15 on Problem 2100
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator