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. P4Lang Repository: Switch

    Github Switch Introduction Structure: +-----+ +-----+ +-----+ +-----+ |App a| |App j| |App n| |App z ...

  2. 每天一点存储知识:集群Nas

    什么是集群Nas 集群是由多个节点构成的一种松散耦合的计算节点集合,协同起来对外提供服务.集群主要分为高性能集群HPC,高可用集群HAC和负载均衡集群LBC.集群Nas是指协同多个节点(通常称为Nas ...

  3. 最优化问题 Optimization Problems & 动态规划 Dynamic Programming

    2018-01-12 22:50:06 一.优化问题 优化问题用数学的角度来分析就是去求一个函数或者说方程的极大值或者极小值,通常这种优化问题是有约束条件的,所以也被称为约束优化问题. 约束优化问题( ...

  4. 20.并发容器之ArrayBlockingQueue和LinkedBlockingQueue实现原理详解

    1. ArrayBlockingQueue简介 在多线程编程过程中,为了业务解耦和架构设计,经常会使用并发容器用于存储多线程间的共享数据,这样不仅可以保证线程安全,还可以简化各个线程操作.例如在“生产 ...

  5. uva 12086 线段树or树状数组练习

    题目链接   https://vjudge.net/problem/34215/origin 这个题就是线段树裸题,有两种操作,实现单点更新和区间和的查找即可,这里第一次学习使用树状数组完成. 二者相 ...

  6. nmcli 使用记录---fatt

    安装nmcli工具 yum install NetworkManager 使用语法 Usage: nmcli [OPTIONS] OBJECT { COMMAND | help } OBJECT g[ ...

  7. 基于java的https双向认证,android上亦可用

    From: http://my.oschina.net/jjface/blog/339144 概述: 客户端,浏览器或者使用http协议和服务器通信的程序. 如: 客户端通过浏览器访问某一网站时,如果 ...

  8. Git的三种区域

    Git的区域分为 工作区.缓存区.本地仓库区   我们先看一张图     GitTest是我本地的一个仓库, 其中GitTest目录就是我们的工作区,但不包括.git这个目录 而.git这个目录就是本 ...

  9. mysqldump 使用方法

    1.仅导出数据: mysqldump -t -uroot -proot pgenius RES_COM_PFT_FCST>RES_COM_PFT_FCST.sql 2.有条的导出数据: mysq ...

  10. Markdown_00_资源帖

    一.官方资料 1.原始官方文档 daringfireball.net 2.官方文档中文版 Markdown 语法说明 (简体中文版) Markdown: Basics (快速入门) 3.Typora官 ...