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 ac#include<iostream> #include<cstring> using namespace std; const int M=12500000; short hash[2*M+1],lb=-50,ub=50; int a,b,c,d,e,x1,x2,x3,x4,x5,count,num; int main(){ while(cin>>a>>b>>c>>d>>e){ memset(hash,0,sizeof(hash)); for(x1=lb;x1<=ub;x1++){ if(!x1)continue; for(x2=lb;x2<=ub;x2++){ if(!x2)continue; hash[M-(a*x1*x1*x1+b*x2*x2*x2)]++; } } count=0; for(x3=lb;x3<=ub;x3++){ if(!x3)continue; for(x4=lb;x4<=ub;x4++){ if(!x4)continue; for(x5=lb;x5<=ub;x5++){ if(!x5)continue; num=M+c*x3*x3*x3+d*x4*x4*x4+e*x5*x5*x5; if((num>=0&num<=2*M)&&hash[num])count+=hash[num]; } } } cout<<count<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator