Consider equations having the following form:

a*x1^2+b*x2^2+c*x3^2+d*x4^2=0 
a, b, c, d are integers from the interval [-50,50] and any of them cannot be 0.

It is consider a solution a system ( x1,x2,x3,x4 ) that verifies the equation, xi is an integer from [-100,100] and xi != 0, any i ∈{1,2,3,4}.

Determine how many solutions satisfy the given equation.

InputThe input consists of several test cases. Each test case consists of a single line containing the 4 coefficients a, b, c, d, separated by one or more blanks. 
End of file.OutputFor each test case, output a single line containing the number of the solutions. 
Sample Input

1 2 3 -4
1 1 1 1

Sample Output

39088
0
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<memory>
#include<map>
#include<cstring>
using namespace std;
int a,b,c,d;
int q[];
int main()
{
int i,j,k,ans;
while(cin>>a>>b>>c>>d){
ans=;
if(a>&&b>&&c>&&d>){
printf("0\n");
continue;
}
if(a<&&b<&&c<&&d<){
printf("0\n");
continue;
}
memset(q,,sizeof(q));
for(i=;i<=;i++)
for(j=;j<=;j++)
q[i*i*a+j*j*b+]++;
for(i=;i<=;i++)
for(j=;j<=;j++)
ans+=q[-i*i*c-j*j*d];
printf("%d\n",ans*);
}
return ;
}

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<memory>
#include<map>
using namespace std;
int a,b,c,d;
map<int,int>q;
int main()
{
int i,j,k,ans;
while(cin>>a>>b>>c>>d){
ans=;
if(a>&&b>&&c>&&d>||a<&&b<&&c<&&d<) //因为x那项永远是正数,如果系数都为正或者为负的时候明显不等于0
{
printf("0\n");
continue;
}
q.clear();
for(i=;i<=;i++)
for(j=;j<=;j++)
q[i*i*a+j*j*b]++;
for(i=;i<=;i++)
for(j=;j<=;j++)
ans+=q[-i*i*c-j*j*d];
printf("%d\n",ans*);
}
return ;
}

 

最新文章

  1. 李洪强iOS经典面试题129
  2. 指定线程执行的顺序---join()
  3. java break语句的三种用法
  4. su - root 报su: incorrect password的错误
  5. Model层数据验证
  6. 【转】Github入门教程
  7. SKProductsRequest ios 7不调用delegate
  8. hdu 4604 Deque(最长上升与下降子序列-能够重复)
  9. 第四篇:R语言数据可视化之折线图、堆积图、堆积面积图
  10. 定时且周期性的任务研究II--ScheduledThreadPoolExecutor
  11. 应对linux下的闰秒
  12. 纯css 构造的tip
  13. BZOJ3575 HNOI2014 道路阻塞
  14. Eclipse打jar包,资源文件的读取
  15. 查看电脑系统参数(Windows)
  16. javascript 之 第七章第三节(this关键字)
  17. jQuery图片自动添加水印插件
  18. Python学习—基础篇之基本数据类型(二)
  19. Primitives vs Objects
  20. Swap Nodes in Pairs LeetCode题解

热门文章

  1. hdu4310 - Hero - 简单的贪心
  2. Python学习札记(八) Basic5 循环
  3. 转载:Service Mesh:重塑微服务市场--敖小剑
  4. Centos7.2 FastDFS_V5.05 集群的安装与配置1
  5. angular2中的路由转场动效
  6. fstat
  7. SpringMVC之ModelAndView的 jsp值在浏览页面不显示
  8. STL学习笔记(转,还是比较全的)
  9. 利用PXE引导安装centos7
  10. 进程上下文频繁切换导致load average过高