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

hash,,注意不要超了内存,计数用short

Posted by lvweihua at 2017-08-13 20:10:42 on Problem 1840
#include<cstdio>
#include<cstring>
typedef long long LL;
const int MAXN=13000000;
short Eq[2*MAXN];
int main(){
    int a1,a2,a3,a4,a5;
    while(scanf("%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5)!=EOF){
         memset(Eq,0,sizeof(Eq));
        for(int i=-50;i<=50;i++){
            for(int j=-50;j<=50;j++){
                if(i==0||j==0)continue;
                Eq[a1*i*i*i+a2*j*j*j+MAXN]++;
            }
        }
        LL ans=0;
        for(int i=-50;i<=50;i++){
            for(int j=-50;j<=50;j++){
                for(int k=-50;k<=50;k++){
                    if(i==0||j==0||k==0)continue;
                    int tmp=MAXN-a3*i*i*i-a4*j*j*j-a5*k*k*k;
                    if(tmp>=0&&tmp<=2*MAXN)ans+=LL(Eq[tmp]);
                }
            }
        }
        printf("%lld",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