Equations
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 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 |
|
Sample Output
39088 |
|
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的更多相关文章
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- A.Kaw矩阵代数初步学习笔记 5. System of Equations
“矩阵代数初步”(Introduction to MATRIX ALGEBRA)课程由Prof. A.K.Kaw(University of South Florida)设计并讲授. PDF格式学习笔 ...
- [家里蹲大学数学杂志]第269期韩青编《A Basic Course in Partial Differential Equations》 前五章习题解答
1.Introduction 2.First-order Differential Equations Exercise2.1. Find solutons of the following inti ...
- Represent code in math equations
Introduce The article shows a way to use math equations to represent code's logical. Key ideas logic ...
- EM basics- the Maxwell Equations
All the two important problems that the EM theory trys to describe and explain are propogation and r ...
- 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 ...
- 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 ...
- zoj 1204 Additive equations
ACCEPT acm作业 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=204 因为老师是在集合那里要我们做这道题.所以我很是天 ...
- Existence and nonexistence results for anisotropic quasilinear elliptic equations
Fragalà, Ilaria; Gazzola, Filippo; Kawohl, Bernd. Existence and nonexistence results for anisotropic ...
- hdu 1496 Equations
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 Equations Description Consider equations having ...
随机推荐
- 关于IOS的屏幕适配(iPhone)——Auto Layout和Size Classes
Auto Layout和Size Classes搭配使用极大的方便了开发者,具体如何使用Auto Layout和Size Classes大家可以参考其他文章或者书籍,这里只提一点,在我们设置Size ...
- myeclipse快捷键(转载)
非常感谢分享这篇文章的大虾..但是我忘了几下您的blog地址,因此无法注明原文地址...见谅哈 存盘 Ctrl+s(肯定知道) 注释代码 Ctrl+/ 取消注释 Ctrl+\(Eclipse3已经都合 ...
- 使用jquery的方法和技巧
1.下载一个jquery.js的文件 2.引入jquery.js文件 <script type="text/javascript" src="__PUBLIC__/ ...
- win32多线程编程
关于多线程多进程的学习,有没有好的书籍我接触的书里头关于多线程多进程部分,一是<操作系统原理>里面讲的相关概念 一个是<linux基础教程>里面讲的很简单的多线程多进程编程 ...
- Java常用异常整理
填坑,整理下Java的常用异常.正确使用异常在实际编码中非常重要,但面试中的意义相对较小,因为对异常的理解和应用很难通过几句话或几行代码考查出来,不过我们至少应答出三点:异常类的继承关系.常用异常类. ...
- sql sever 基础知识及详细笔记
第六章:程序数据集散地:数据库 6.1:当今最常用的数据库 sql server:是微软公司的产品 oracle:是甲骨文公司的产品 DB2:数据核心又称DB2通用服务器 Mysql:是一种开发源代 ...
- input输入中文时,拼音在输入框内会触发input事件的问题。
问题描述: 监听文本输入框的input事件,在拼写汉字(输入法)但汉字并未实际填充到文本框中(选词)时会触发input事件,如图: 需要完成的需求就是在输入阶段不触发input中的事件,选词之后文字落 ...
- RobotFramework自动化测试框架-移动手机自动化测试Click Element关键字的使用
Click Element关键字用来模拟点击APP界面上的一个元素,该关键字接收一个参数[ locator ] ,这里的locator指的是界面元素的定位方式. 示例1:使用Click Element ...
- 【转】Python-__builtin__与__builtins__的区别与关系(超详细,经典)
在学习Python时,很多人会问到__builtin__.__builtins__和builtins之间有什么关系.百度或Google一下,有很 多答案,但是这些答案要么不准确,要么只说了一点点,并不 ...
- 【转】python time模块详解
python 的内嵌time模板翻译及说明 一.简介 time模块提供各种操作时间的函数 说明:一般有两种表示时间的方式: 第一种是时间戳的方式(相对于1970.1.1 00:00:0 ...