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 ...
随机推荐
- 保存数据到sdcard中去
这里只贴上核心的代码:其它自行脑补!
- Java 基础语法
一.关键字 定义:被 Java 赋予特殊含义的单词. 特点:基本上都是英文小写. 用于定义数据类型的关键字 基本数据类型 整数型(默认为 int) byte(8 位,1 字节,默认值是 0,最大存储数 ...
- 剑指offer(纪念版) 面试题3:二维数组中的查找
题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数. 第一种方法题目说不可行 ...
- jP61 2.15
import java.util.Scanner; public class Distance { public static void main(String[] args) { Scanne ...
- 简单Elixir游戏服设计-玩家进程跑起来
有了玩家模型,我们试试让玩家进程跑起来. 需要搞个PlayerSupervisor来负责启动和监控玩家进程. defmodule PlayerSupervisor do use Supervisor ...
- Hadoop(三)手把手教你搭建Hadoop全分布式集群
前言 上一篇介绍了伪分布式集群的搭建,其实在我们的生产环境中我们肯定不是使用只有一台服务器的伪分布式集群当中的.接下来我将给大家分享一下全分布式集群的搭建! 其实搭建最基本的全分布式集群和伪分布式集群 ...
- ch3-模板语法({{}} v-html v-bind:id 表达式 指令 修饰符 过滤器)
1 模板语法 Vue.js 使用了基于 HTML 的模版语法,允许开发者声明式地将 DOM 绑定至底层 Vue 实例的数据. 所有 Vue.js 的模板都是合法的 HTML ,所以能被遵循规范的浏览器 ...
- centos 7.1系统更改Mariadb数据存储位置步骤分享
一.首先确保你要更改Mariadb数据存储的位置的空间够大 现在已将Mariadb存储位置更改到/opt/目录下 1.然后将Mariadb服务stop:systemctl stop mariadb 2 ...
- zoj1797 Least Common Multiple 最小公倍数
Least Common Multiple Time Limit: 2 Seconds Memory Limit: 65536 KB The least common multiple (L ...
- 项目常见函数封装,基于Jquery
/// <reference path="jquery-1.8.0.min.js" /> /* * DIV或元素居中 * @return */ jQuery.fn.mC ...