Eqs
Time Limit: 5000MS   Memory Limit: 65536K
Total Submissions: 13967   Accepted: 6858

Description

Consider equations having the following form:
a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a system (x1, x2, x3, x4, x5) that verifies the equation, xi∈[-50,50], xi != 0, any i∈{1,2,3,4,5}.
Determine how many solutions satisfy the given equation.

Input

The only line of input contains the 5 coefficients a1, a2, a3, a4, a5, separated by blanks.

Output

The output will contain on the first line the number of the solutions for the given equation.

Sample Input

37 29 41 43 47

Sample Output

654

Source

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int hash[];
int main(){
int a,b,c,d,e;
while(cin>>a>>b>>c>>d>>e){
memset(hash,,sizeof(hash));
int cnt=;
for(int i=-;i<=;i++){
if(i==)
continue;
for(int j=-;j<=;j++){
if(j==)
continue;
for(int k=-;k<=;k++){
if(k==)
continue;
int temp=i*i*i*a+j*j*j*b+k*k*k*c;
hash[cnt++]=temp;
}
}
}
int ans=;
sort(hash,hash+cnt);
for(int i=-;i<=;i++){
if(i==)
continue;
for(int j=-;j<=;j++){
if(j==)
continue;
int temp2=i*i*i*e+j*j*j*d;
ans+=upper_bound(hash,hash+cnt,temp2)-lower_bound(hash,hash+cnt,temp2);
}
} printf("%d\n",ans); }
return ;
}

poj 1840 枚举的更多相关文章

  1. poj 1840 Eqs 【解五元方程+分治+枚举打表+二分查找所有key 】

    Eqs Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 13955   Accepted: 6851 Description ...

  2. POJ 1840 HASH

    题目链接:http://poj.org/problem?id=1840 题意:公式a1x1^3+ a2x2^3+ a3x3^3+ a4x4^3+ a5x5^3=0,现在给定a1~a5,求有多少个(x1 ...

  3. poj 1840 Eqs (hash)

    题目:http://poj.org/problem?id=1840 题解:http://blog.csdn.net/lyy289065406/article/details/6647387 小优姐讲的 ...

  4. POJ 1840 Eps 解题报告(哈希)

    a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0,xi∈[-50,50],且xi!=0.让我们求所有解的可能. 首先,如果暴力判断的话,每个x的取值有100种可能,100^5肯定 ...

  5. POJ 1840 Eqs 解方程式, 水题 难度:0

    题目 http://poj.org/problem?id=1840 题意 给 与数组a[5],其中-50<=a[i]<=50,0<=i<5,求有多少组不同的x[5],使得a[0 ...

  6. POJ - 1080 枚举 / DP

    要求max{F/P},先枚举下界lowf,再贪心求符合约束条件的n个最小价值和 记录F的离散值和去重可以大幅度常数优化 (本来想着用DP做的) (辣鸡POJ连auto都Complie Error) # ...

  7. poj 3189(枚举+多重匹配)

    题目链接:http://poj.org/problem?id=3189 思路:由于题目要求最小的差值,而Range最多也才20,因此我们可以枚举上下限,多重匹配验证即可. http://paste.u ...

  8. POJ 1753 (枚举+DFS)

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 40632   Accepted: 17647 Descr ...

  9. POJ 1840 Brainman(逆序对数)

    题目链接:http://poj.org/problem?id=1804 题意:给定一个序列a[],每次只允许交换相邻两个数,最少要交换多少次才能把它变成非递降序列. 思路:题目就是要求逆序对数,我们知 ...

随机推荐

  1. 在IDEA中创建Maven项目和添加tomcat

    IDEA中创建是一种创建maven项目的办法,但不推荐,因为没有使用统一的骨架,可以一开始就选择创建maven项目,步骤如下: 第一步 第二步:设置项目 第三步:进行配置好maven,加上 arche ...

  2. Git配置和常用命令

    Git配置 git config --global user.name "hunng" git config --global user.email "huangthin ...

  3. js 实现序列号效果实现

    前端的朋友可能遇到过这样的需求,要求在页面输入一串序列号,或激活码(就像在PC正版软件中的序列号),可是HTML中并没有为我们提供类似的组件,我们来自己实现一个: 大体的思路是在表单里有一个隐藏的in ...

  4. java数据库 JDBC操作MySQL数据库常用API 部门表和员工表 创建表 添加数据 查询数据

    package com.swift.department; import java.sql.Connection; import java.sql.PreparedStatement; import ...

  5. Python 初始—(迭代器和生成器)

    生成器也是一个迭代器,通过next()函数实现按需计算下一个数据列表生成器,使代码变得更加简洁,只记录当前的位置,只有__next__(), (i*2 for i in range(10)) 生成器( ...

  6. 易语言调用C++写的DLL

    直接调用会弹出堆栈错误的信息,原因是VS默认是__cdcel方式,而易语言是__stdcall,所以调用约定不一致导致堆栈错误. 解决方案很简单,易语言声明DLL函数时“在库中对应命令名”函数名前加一 ...

  7. Eclipse+Python环境配置

    Eclipse+Pydev 1.安装Eclipse Eclipse可以在它的官方网站Eclipse.org找到并下载,通常我们可以选择适合自己的Eclipse版本,比如Eclipse Classic. ...

  8. 关于TP3.2框架读取Sql server中文字段数据以及处理乱码的一些小心得

    最近要做一个项目,需要使用TP3.2框架,之前什么也不会,就硬着头皮上了,结果真的闹了挺多emmmmmm挺低级的错误,就像SQL Server中文字段的读取,一开始我是照着读取英文字段的格式来写的,在 ...

  9. nginx+php整合(是让nginx可以运行php,以及下载地址)

    下载地址: nginx:http://nginx.org/en/download.html PHP: https://windows.php.net/download/ 都是官网的自己选择版本 安装文 ...

  10. thinkphp3.2 where 条件查询 复查的查询语句

    复查的查询语句 有的时候,我们希望通过一次的查询就能解决问题,这个时候查询条件往往比较复杂,但是却比多次查询库来的高效. 实在是搞不定的话就直接用$where[‘_string’] = ‘xxxx’, ...