HDU1496 Equations 卡时间第二题
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 卡时间第二题的更多相关文章
- Leetcode春季打卡活动 第二题:206. 反转链表
Leetcode春季打卡活动 第二题:206. 反转链表 206. 反转链表 Talk is cheap . Show me the code . /** * Definition for singl ...
- 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 ...
- 05:统计单词数【NOIP2011复赛普及组第二题】
05:统计单词数 总时间限制: 1000ms 内存限制: 65536kB 描述 一般的文本编辑器都有查找单词的功能,该功能可以快速定位特定单词在文章中的位置,有的还能统计出特定单词在文章中出现的次 ...
- 常见面试第二题之什么是Context
今天的面试题,也就是我们常见面试题系列的第二题,我们来讲一讲android中的context.我相信大家android开发者一定对于这个context非常熟悉,肯定都有使用过,肯定没有没使用过的.但是 ...
- 《学习OpenCV》练习题第五章第二题abc
代码: #include <stdio.h> #include <opencv/highgui.h> #include <opencv/cv.h> #include ...
- 《学习OpenCV》练习题第四章第二题
#include <highgui.h> #include <cv.h> #pragma comment (lib,"opencv_calib3d231d.lib&q ...
- test20181020 B君的第二题
题意 分析 考场70分 一看就是裸的kmp,直接打上去. #include<cstdlib> #include<cstdio> #include<cmath> #i ...
- “玲珑杯”ACM比赛 Round #11 " ---1097 - 萌萌哒的第二题
1097 - 萌萌哒的第二题 题意:中文题好像没有必要说题意了吧.. 思路:我们知道由于运输桥不能交叉,所以从右往左所修建的桥的序号是严格单增的.但是每个工厂B有6种选择,只能选一个求最多能建造几座桥 ...
- python解无忧公主的数学时间编程题001.py
python解无忧公主的数学时间编程题001.py """ python解无忧公主的数学时间编程题001.py http://mp.weixin.qq.com/s?__b ...
随机推荐
- 数据结构——堆(Heap)大根堆、小根堆
目录 Heap是一种数据结构具有以下的特点: 1)完全二叉树: 2)heap中存储的值是偏序: Min-heap: 父节点的值小于或等于子节点的值: Max-heap: 父节点的值大于或等于子节点的值 ...
- jQuery实际案例③——手风琴的效果
如图,用最简单的方式实现手风琴的效果,核心,就是通过改变自身即鼠标移上去的那张图的width,与其他的width就可,但是需要用animate,先改变自己的width,再改变其他的.
- 英语每日阅读---4、VOA慢速英语(翻译+字幕+讲解):专家:城市发展将加剧住房危机
英语每日阅读---4.VOA慢速英语(翻译+字幕+讲解):专家:城市发展将加剧住房危机 一.总结 一句话总结:城市化(越来越多的人会住进城市)是必然趋势,人口增长也是必然趋势,人口增长必然会加大住房危 ...
- FlexboxLayout——Android弹性布局
FlexboxLayout是一个Android平台上与CSS的 Flexible box 弹性盒子布局模块 有相似功能的库.Flexbox 是CSS 的一种布局方案,可以简单.快捷的实现复杂布局. F ...
- Java笔试之输入输出
在校招笔试中,有的时候我们要自己设计输入输出,下面罗列一些常见的输入输出: 首先把输入包加载进来: import java.util.* ; 一 ,输入 1,输入一个整数,浮点数,输入一个数组 : p ...
- ubuntu中python2与python3的默认启动切换
方法摘自SegmentFault: 方法一: echo alias python=python3 >> ~/.bashrc && source ~/.bashrc相当于先打 ...
- python2.7安装requests
我这里的是linux CentOS7版本 直接执行命令pip install requests 安装即可,如果提示没有pip这个命令要先安装pip 安装步骤如下: 1. 首先检查Linux有没有安装P ...
- GlusterFS原创资源
学习博客: GlusterFS原创资源
- c# 使用SqlBulkCopy 提高大数据插入数据库速度
自己得一点总结: 1.BulkCopy采用的是插入方式,不是覆盖方式(原数据不动,在原数据的后面复制上dataTable中的内容) 2.自增的字段不用赋值 3.数据库字段名和dataTable列名可以 ...
- 【lightoj-1024】Eid (高精度)
[题意] 给定n个数,求这n个数的最小公倍数. [题解] 最小公倍数当然不能按常规方法来求,因为最大的数将近是10000^1000级别的.然鹅最小公倍数怎么搞呢? 这里发现了一个规律: 4 5 6 3 ...