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. 继承FileInputFormat类来理解 FileInputFormat类

    import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.had ...

  2. 转 IOS7开发错误收集

    转自:http://blog.csdn.net/smallsky_keke/article/details/16117653 1. fatal error: file '/Applications/X ...

  3. c++标准之IO库

    1.面向对象的标准库 2.多种IO标准库工具 istream,提供输入操作 ostream,提供输出操作 cin:读入标准输入的istream对象.全局对象extern std::istream ci ...

  4. MySQL另类的备份恢复方法——innodb可传输表空间

      Preface       There're many ways in backing up or migrating data from one server to another one.Lo ...

  5. hadoop-2.0.0-cdh4.1.2升级到hadoop-2.7.2

    升级前准备: 如果是 centos6.x的系统得升级glibc和pam包 在/etc/ld.so.conf 文件里添加 /usr/src/jdk1.6.0_23/jre/lib/amd64/serve ...

  6. linux下Tomcat配置提示权限不够解决办法

    在终端输入命令 sudo chmod -R 777 /opt/Tomcat,那么Tomcat文件夹和它下面的所有子文件夹的属性都变成了777(读/写/执行权限)

  7. angularjs处理多个$http

    本文引自:https://www.cnblogs.com/xiaojikuaipao/p/6017899.html 在实际业务中经常需要等待几个请求完成后再进行下一步操作.但angularjs中$ht ...

  8. xml中Node和Element的区别

    本文转载自:http://blog.csdn.net/wcydiyi/article/details/4432636点击打开链接 1.元素(Element)和结点(Node)的区别:         ...

  9. bin/postconf: error while loading shared libraries: libmysqlclient

    今天在编译安装postfix的时候 make install 出现如下错误 bin/postconf: error while loading shared libraries: libmysqlcl ...

  10. you do not permission to access / no this server

    最近在学习Linux下的httpd服务,自己写了一个虚拟主机的配置文件 重启之后,怎么访问都是出现以下的内容, do not permission to access / no this server ...