Equations

Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 82 Accepted Submission(s): 54
 
Problem Description
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.

 
Input
The 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.
 
Output
For 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
 
Author
LL
 
Source
“2006校园文化活动月”之“校庆杯”大学生程序设计竞赛暨杭州电子科技大学第四届大学生程序设计竞赛
 
Recommend
LL
 
/*
题意:给你a,b,c,d然后让你输出满足条件的 x1,x2,x3,x4 的组数 初步思路:打表乱搞一下 #放弃了:打了半小时了,还没有打完。想一下可以将整个式子分成两半,求两半加起来是零的个数
*/
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int f1[];//正的结果
int f2[];//负的结果
int main(){
// freopen("in.txt","r",stdin);
while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF){
if((a>&&b>&&c>&&d>)||(a<&&b<&&c<&&d<)){
printf("0\n");
continue;
}
memset(f1,,sizeof f1);
memset(f2,,sizeof f2);
long long s=;
for(int i=-;i<=;i++){
if(i==) continue;
for(int j=-;j<=;j++){
if(j==) continue;
int k=a*i*i+b*j*j;
if(k>=) f1[k]++;
else f2[-k]++;
}
}
for(int i=-;i<=;i++){
if(i==) continue;
for(int j=-;j<=;j++){
if(j==) continue;
int k=c*i*i+d*j*j;
if(k>) s+=f2[k];
else s+=f1[-k];
}
}
printf("%lld\n",s);
}
return ;
}

Equations的更多相关文章

  1. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  2. A.Kaw矩阵代数初步学习笔记 5. System of Equations

    “矩阵代数初步”(Introduction to MATRIX ALGEBRA)课程由Prof. A.K.Kaw(University of South Florida)设计并讲授. PDF格式学习笔 ...

  3. [家里蹲大学数学杂志]第269期韩青编《A Basic Course in Partial Differential Equations》 前五章习题解答

    1.Introduction 2.First-order Differential Equations Exercise2.1. Find solutons of the following inti ...

  4. Represent code in math equations

    Introduce The article shows a way to use math equations to represent code's logical. Key ideas logic ...

  5. EM basics- the Maxwell Equations

    All the two important problems that the EM theory trys to describe and explain are propogation and r ...

  6. FITTING A MODEL VIA CLOSED-FORM EQUATIONS VS. GRADIENT DESCENT VS STOCHASTIC GRADIENT DESCENT VS MINI-BATCH LEARNING. WHAT IS THE DIFFERENCE?

    FITTING A MODEL VIA CLOSED-FORM EQUATIONS VS. GRADIENT DESCENT VS STOCHASTIC GRADIENT DESCENT VS MIN ...

  7. ACM题目————Equations

    Description Consider equations having the following form: a*x1^2+b*x2^2+c*x3^2+d*x4^2=0 a, b, c, d a ...

  8. zoj 1204 Additive equations

    ACCEPT acm作业 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=204 因为老师是在集合那里要我们做这道题.所以我很是天 ...

  9. Existence and nonexistence results for anisotropic quasilinear elliptic equations

    Fragalà, Ilaria; Gazzola, Filippo; Kawohl, Bernd. Existence and nonexistence results for anisotropic ...

  10. hdu 1496 Equations

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 Equations Description Consider equations having ...

随机推荐

  1. Zabbix通过SNMP监控多核CPU使用率时, 计算CPU平均使用率

    环境:没有Agent,只能通过SNMP监控时,需要获取多核CPU的平均使用率. ZABBIX的使用SNMP监控CPU使用率时,由于设备都是多核CPU,监控的都是单独某一核心的使用率,但单独某一核使用率 ...

  2. ng-model值字符串转数值型(convertToNumber directive)

    <select ng-model="model.id" convert-to-number> <option value="0">Zer ...

  3. Python 接口测试(五)

    五:使用python进行组织编写接口测试用例 接口测试其实就是几个步骤. 拿到接口的url地址 查看接口是用什么方式发送 添加请求头,请求体 发送查看返回结果,校验返回结果是否正确 明白了接口测试的测 ...

  4. Poj 1032 Parliament

    Parliament Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19103   Accepted: 8101 Descr ...

  5. #define WIN32_LEAN_AND_MEAN

    不加载MFC所需的模块.用英语解释:Say no to MFC如果你的工程不使用MFC,就加上这句,这样一来在编译链接时,包括最后生成的一些供调试用的模块时,速度更快,容量更小.不过对于较大工程,MF ...

  6. python爬取煎蛋网图片

    ``` py2版本: #-*- coding:utf-8 -*-#from __future__ import unicode_literimport urllib,urllib2,timeimpor ...

  7. 【转】Python中实现远程调用(RPC、RMI)简单例子

    远程调用使得调用远程服务器的对象.方法的方式就和调用本地对象.方法的方式差不多,因为我们通过网络编程把这些都隐藏起来了.远程调用是分布式系统的基础. 远程调用一般分为两种,远程过程调用(RPC)和远程 ...

  8. RobotFramework自动化测试框架-移动手机自动化测试Click Element At Coordinates关键字的使用

    Click Element At Coordinates关键字通过一个具体的坐标点,来模拟点击一个Element,该关键字接收两个参数[ coordinate_X | coordinate_Y ]. ...

  9. 苹果 AR 新专利马上登陆 Facetime|Facebook 要用 VR 玩直播

    附上VR技术福利视频 链接: https://pan.baidu.com/s/1boGGVs7 密码: viy8 点击关注有更多VR技术资源哦 苹果 AR 新专利马上登陆 Facetime ,使用光场 ...

  10. Re-Order Buffer

    Re-order Buffer(ROB)是处理器中非常重要的一个模块,它位于renamer与scheduler(RS)之间,并且也是execution unit(EU)的出口.ROB作为指令处理的后端 ...