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

请大牛给我看看这题为什么错

Posted by jlnu123 at 2008-11-30 14:50:41 on Problem 2100
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
long long a[50][2];
int main()
{
	long long n;	
	cin>>n;
    long long max = (long long)cbrt(3*n)+100;
	
	long long i,j,k;
	long long num=0;
	j=0;
	for(k=0;k<=max;++k)
	{
		long long t=(1+k)*k*((1+k)*k)-4*(k+1)*(k*(k+1)*(2*k+1)/6-n);
		if(t>=0)
		{
			i=(-(1+k)*k+(long long)sqrt(t))/(2*k+2);
			if((k+1)*i*i+(1+k)*k*i+k*(k+1)*(2*k+1)/6==n && i>0)
			{
				++num;
				a[j][0]=k+1;
				a[j][1]=i;
				++j;
			}
		}
	}
	cout<<num<<endl;
	for(i=num-1;i>=0;--i)
	{
        cout<<a[i][0];                 
		for(j=0;j<a[i][0];++j)
		   cout<<" "<<j+a[i][1];
        cout<<endl;
	}

	//system("pause");
    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