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

为什么会wa啊??大牛帮我看一下

Posted by 200892458 at 2009-10-12 20:06:52 on Problem 2100
#include <iostream>
#include<cmath>
using namespace std;
long long n;
struct pale
{
    long long x,k;
};
pale res[100000];
long long sum(long long x,long long k)
{
    return (k+1)*x*x+k*(k+1)*x+k*(k+1)*(2*k+1)/6;
}
long long gcd(long long a,long long b)
{
    if(b==0)
    return a;
    else return gcd(b,a%b);
}
int main()
{
    while(cin>>n)
    {
        if(n==0)
           break;
        long long root3;
        root3=(long long)exp(log((double )n*24)/3)/2;
        long long x,k,num=0,i;
        for(k=root3;k>=0;k--)
        {
            long long a=4*n;
            long long b=k*(k+1)*(k+2)/3;
            long long d=gcd(a,b);
             x=(long long)((sqrt(a/d-b/d)*sqrt(k+1)*sqrt(d))-k*(k+1))/(2*k+2);
             if(root3==k)
             cout<<x<<endl;
             if(n==sum(x,k)&&x>0)
             {
                 res[num].x=x;res[num++].k=k;
              }
        }
        cout<<num<<endl;
        for(i=0;i<num;i++)
        {
            cout<<res[i].k+1<<" ";
            for(k=0;k<=res[i].k;k++)
            cout<<res[i].x+k<<" ";
            cout<<endl;
        }
    }
    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