POJ 1840 Eqs 暴力
|
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 Romania OI 2002
|
题目大意:给a1, a2, a3, a4, a5,5个数且 xi∈[-50,50],xi != 0, any i∈{1,2,3,4,5}.求出有多少种解使得a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0
题解:5个for肯定会超时(1e8),可以分开考虑,移项可以得到-a1x13- a2x23= a3x33+ a4x43+ a5x53,把左边所有的可能存在数组里,右边查询即可,左边可能为负数,所以两边同时加上25001000
#include <stdio.h>
char mp[];
int main()
{
int t,i, j, k,a2, a1, a3,a4,a5;
scanf("%d%d%d%d%d", &a1, &a2, &a3, &a4, &a5);
for(j=-;j<=;j++)
for(k=-;k<=;k++)
if(j!=&&k!=)
mp[a1*j*j*j+a2*k*k*k+]++;
for(t=,i=-;i<=;i++)
for(j=-;j<=;j++)
for(k=-;k<=;k++)
if(i!=&&j!=&&k!=)
t += mp[-a3*k*k*k-i*i*i*a4-j*j*j*a5];
printf("%d\n", t);
return ;
}
POJ 1840 Eqs 暴力的更多相关文章
- poj 1840 Eqs (hash)
题目:http://poj.org/problem?id=1840 题解:http://blog.csdn.net/lyy289065406/article/details/6647387 小优姐讲的 ...
- POJ 1840 Eqs 解方程式, 水题 难度:0
题目 http://poj.org/problem?id=1840 题意 给 与数组a[5],其中-50<=a[i]<=50,0<=i<5,求有多少组不同的x[5],使得a[0 ...
- POJ 1840 Eqs
Eqs Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 15010 Accepted: 7366 Description ...
- POJ 1840 Eqs 二分+map/hash
Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The co ...
- POJ 1840 Eqs(乱搞)题解
思路:这题好像以前有类似的讲过,我们把等式移一下,变成 -(a1*x1^3 + a2*x2^3)== a3*x3^3 + a4*x4^3 + a5*x5^3,那么我们只要先预处理求出左边的答案,然后再 ...
- poj 1840 Eqs 【解五元方程+分治+枚举打表+二分查找所有key 】
Eqs Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 13955 Accepted: 6851 Description ...
- POJ 1840 Eqs(hash)
题意 输入a1,a2,a3,a4,a5 求有多少种不同的x1,x2,x3,x4,x5序列使得等式成立 a,x取值在-50到50之间 直接暴力的话肯定会超时的 100的五次方 10e了都 ...
- poj 1840 暴力+标记
Description Consider equations having the following form: a1x1 3+ a2x2 3+ a3x3 3+ a4x4 3+ a5x5 3=0 T ...
- Eqs - poj 1840(hash)
题意:对于方程:a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 ,有xi∈[-50,50], xi != 0, any i∈{1,2,3,4,5}. 现在给出a1,a2,a3, ...
随机推荐
- scala2.10.x case classes cannot have more than 22 parameters
问题 这个错误出现在case class参数超出22个的时候. case classes cannot have more than 22 parameters 在scala 2.11.x版本以下时c ...
- 夺命雷公狗ThinkPHP项目之----企业网站26之网站前台列表页的显示和完成分页功能
我们用大I接收到我们get过来的栏目页的id然后通过文章的ar_cateid 来判断是不是属于该栏目下的,如果文章表ar_cateid = 栏目表的cate_id 那么就可以选出我们要查找的信息, 然 ...
- 博创arm板编译内核makefile不兼容问题解决
导致这种结果的是:Make工具对低版本内核的Makefile一些旧的规则兼容不好,我们只需修改对应的Makefile. 改1:: 原始的: 大概在 1503行 / %/: prepa ...
- Yii多表关联
表结构 现在有客户表.订单表.图书表.作者表, 客户表Customer (id customer_name) 订单表Order (id order_name ...
- Inside TSQL Querying - Chapter 2. Physical Query Processing
Summary Description The SQL language is spoken by most database experts, and all relational database ...
- Sqlserver Sql Agent Job 只能同时有一个实例运行
Sqlserver Sql Agent中的Job默认情况下只能有一个实例在运行,也就是说假如你的Sql Agent里面有一个正在运行的Job叫"Test Job",如果你现在再去启 ...
- Nginx防蜘蛛爬虫处理
假定一个场景:某个网站它可能不希望被网络爬虫抓取,例如测试环境不希望被抓取,以免对用户造成误导,那么需要在该网站中申明,本站不希望被抓取.有如下方法: 方法一:修改nginx.conf,禁止网络爬虫的 ...
- ubuntu使用记录
常用指令 ls 显示文件或目录 -l 列出文件详细信息l(list) -a 列出当前目录下所有文件及目录,包括隐藏的a(all) mkdir ...
- React笔记_(1)_react概述
React概述 React是一种很好的前端技术. 它将应用打散成独立的小模块,然后进行组装,完成开发. react远比angularjs难学的多. react依赖的如webpack等各种工具得先学 ...
- linux C判断文件是否存在【转】
转自:http://blog.csdn.net/kingjo002/article/details/8442146 一.access函数 功能描述: 检查调用进程是否可以对指定的文件执行某种操作. 用 ...