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 ;
}

 

HDU1496 Equations 卡时间第二题的更多相关文章

  1. Leetcode春季打卡活动 第二题:206. 反转链表

    Leetcode春季打卡活动 第二题:206. 反转链表 206. 反转链表 Talk is cheap . Show me the code . /** * Definition for singl ...

  2. HDU3833 YY's new problem 卡时间第一题

    Given a permutation P of 1 to N, YY wants to know whether there exists such three elements P[i 1], P ...

  3. 05:统计单词数【NOIP2011复赛普及组第二题】

    05:统计单词数 总时间限制:  1000ms 内存限制:  65536kB 描述 一般的文本编辑器都有查找单词的功能,该功能可以快速定位特定单词在文章中的位置,有的还能统计出特定单词在文章中出现的次 ...

  4. 常见面试第二题之什么是Context

    今天的面试题,也就是我们常见面试题系列的第二题,我们来讲一讲android中的context.我相信大家android开发者一定对于这个context非常熟悉,肯定都有使用过,肯定没有没使用过的.但是 ...

  5. 《学习OpenCV》练习题第五章第二题abc

    代码: #include <stdio.h> #include <opencv/highgui.h> #include <opencv/cv.h> #include ...

  6. 《学习OpenCV》练习题第四章第二题

    #include <highgui.h> #include <cv.h> #pragma comment (lib,"opencv_calib3d231d.lib&q ...

  7. test20181020 B君的第二题

    题意 分析 考场70分 一看就是裸的kmp,直接打上去. #include<cstdlib> #include<cstdio> #include<cmath> #i ...

  8. “玲珑杯”ACM比赛 Round #11 " ---1097 - 萌萌哒的第二题

    1097 - 萌萌哒的第二题 题意:中文题好像没有必要说题意了吧.. 思路:我们知道由于运输桥不能交叉,所以从右往左所修建的桥的序号是严格单增的.但是每个工厂B有6种选择,只能选一个求最多能建造几座桥 ...

  9. python解无忧公主的数学时间编程题001.py

    python解无忧公主的数学时间编程题001.py """ python解无忧公主的数学时间编程题001.py http://mp.weixin.qq.com/s?__b ...

随机推荐

  1. Kubernetes 部署失败的 10 个最普遍原因

    [原文].后面我们可能还会看到一个 OOMKilled 错误. 我们的应用正在挂掉?为什么? 首先我们查看应用日志.假定你发送应用日志到 stdout(事实上你也应该这么做),你可以使用 kubect ...

  2. Linux段错误及GDB Coredump调试方法

    最近在Linux环境下做C语言项目,由于是在一个原有项目基础之上进行二次开发,而且项目工程庞大复杂,出现了不少问题,其中遇到最多.花费时间最长的问题就是著名的“段错误”(Segmentation Fa ...

  3. Android -- 文件上传到服务器

    1. 文件上传的两种方式 (1) HttpClient (2)AsyncHttpClient (开源框架: https://github.com/loopj/android-async-http) 示 ...

  4. PHPCMSV9的CKEDITOR编辑器增加行距

    lineheight插件,下载地址:http://files.cnblogs.com/ysfng/ckeditor-lineheight.zip 第一步,下载lineheight插件,并解压到\cke ...

  5. [postgresql]ROWS is not applicable when function does not return a set问题解决

    需要把程序结尾的ROWS 1000去掉,提示如果函数不是返回一个数据集的情况下ROWS是不适用的: CREATE OR REPLACE FUNCTION public.function( eigyou ...

  6. 基于JQuery 的消息提示框效果代码

    提示框效果 一下是封装到 Jquery.L.Message.js 中的JS文件内容 var returnurl = ''; var messagebox_timer; $.fn.messagebox ...

  7. 转载:Object的create方法文档

    源地址:https://developer.mozilla.org/zh-CN/docs/JavaScript/Reference/Global_Objects/Object/create#.E4.B ...

  8. c# out ref 多个返回值问题个人总结

    多个返回值可以用ref或者out来实现 如 var b=string.Empty(); var c=string.Empty(); public bool Test(string a, out str ...

  9. 十四、dbms_obfuscation_toolkit(用于加密和解密应用数据)

    1.概述 作用:用于加密和解密应用数据,另外还可以生成密码检验和.通过加密输入数据,可以防止黑客或其他用户窃取私有数据;而通过结合使用加密和密码检验和,可以防止黑客破坏初加密的数据.当使用该包加密数据 ...

  10. 安装Fedora 21工作站后要做的10件事情

    教程]安装Fedora 21工作站后要做的10件事情 2015-01-07 13:32 CSDN CODE 作者CSDN CODE 1 755 FedoraGNOMELinux Fedora 21已经 ...