Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
hash,,注意不要超了内存,计数用short#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator