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 CKboss at 2013-09-09 17:54:55 on Problem 1840
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a,b,c,d,e;

int hash[2000000];

int main()
{
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    int cnt=0;
    for(int i=-50;i<=50;i++)
    {
        if(i==0) continue;
        for(int j=-50;j<=50;j++)
        {
            if(j==0) continue;
            for(int k=-50;k<=50;k++)
            {
                if(k==0) continue;
                int tmp=i*i*i*a+j*j*j*b+k*k*k*c;
                hash[cnt++]=tmp;
            }
        }
    }
    sort(hash,hash+cnt);
    int ans=0;
    for(int i=-50;i<=50;i++)
    {
        if(i==0) continue;
        for(int j=-50;j<=50;j++)
        {
            if(j==0) continue;
            int tmp=i*i*i*d+j*j*j*e;
            ans+=upper_bound(hash,hash+cnt,-tmp)-lower_bound(hash,hash+cnt,-tmp);
        }
    }

    printf("%d\n",ans);

    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