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

我对拍没有发现错误啊,为什么Wrong Answer

Posted by foranswer at 2006-09-09 15:08:21 on Problem 2100
#include <iostream>
#include <cmath>

using namespace std;

#define MAX 1000

__int64 x[MAX], k[MAX];

int main()
{
        __int64 n, i, j, num, t, a, b, c, deta, x1, x2;
        while(scanf("%I64d", &n) != EOF)
        {
                t = 0, num = 0;
                while((t + 1) * (t + 2) * (2 * t + 3) <= 6 * n)
                {
                        a = t + 1, b = t * (t + 1), c = (t * (t + 1) * (2 * t + 1)) / 6 - n;
                        deta = b * b - 4 * a * c;
                        if(deta >= 0)
                        {
                                __int64 temp = (__int64) sqrt(deta);
                                if(temp * temp == deta && temp > b && ((-1) * b + temp) % (2 * a) == 0)
                                {
                                        x1 = ((-1) * b + temp) / (2 * a);
                                        x2 = ((-1) * b - temp) / (2 * a);
                                        x[num] = x1;
                                        k[num] = t + 1;
                                        __int64 sum = 0;
                                        for(i = 0; i < t + 1; i++)
                                        {
                                                sum += x1 * x1;
                                                x1++;
                                        }
                                        if(sum == n)
                                        {
                                                num++;
                                        }
                                }
                        }
                        t++;
                }
                printf("%I64d\n", num);
                for(i = num - 1; i >= 0; i--)
                {
                        printf("%I64d ", k[i]);
                        for(j = 0; j < k[i]; j++)
                        {
                                printf("%I64d ", x[i]++);
                        }
                        putchar('\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