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 暴力的更多相关文章

  1. poj 1840 Eqs (hash)

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

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

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

  3. POJ 1840 Eqs

    Eqs Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 15010   Accepted: 7366 Description ...

  4. POJ 1840 Eqs 二分+map/hash

    Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The co ...

  5. POJ 1840 Eqs(乱搞)题解

    思路:这题好像以前有类似的讲过,我们把等式移一下,变成 -(a1*x1^3 + a2*x2^3)== a3*x3^3 + a4*x4^3 + a5*x5^3,那么我们只要先预处理求出左边的答案,然后再 ...

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

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

  7. POJ 1840 Eqs(hash)

    题意  输入a1,a2,a3,a4,a5  求有多少种不同的x1,x2,x3,x4,x5序列使得等式成立   a,x取值在-50到50之间 直接暴力的话肯定会超时的   100的五次方  10e了都 ...

  8. poj 1840 暴力+标记

    Description Consider equations having the following form: a1x1 3+ a2x2 3+ a3x3 3+ a4x4 3+ a5x5 3=0 T ...

  9. 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, ...

随机推荐

  1. 关于 VS 无法转到定义和无法转到使用的问题

    今天提交完代码以后突然发现  咦  怎么F12 .点击右键的方法都不能转到定义了    转到引用 也提示  没有发现   重启VS  还是不行 .去找王晓  他也不清楚(其实我知道 他应该也不清楚  ...

  2. qsort函数用法(转)

    qsort函数用法   qsort 功 能: 使用快速排序例程进行排序  用 法: void qsort(void *base, int nelem, int width, int (*fcmp)(c ...

  3. opengl& 颜色

    颜色 简介 颜色的显示模式分为两种: RGBA显示模式 颜色索引显示模式(使用颜色映射表,映射表提供了索引,可以混合基本的红,绿,蓝色值). RGBA模式可以选择的颜色数量多于颜色索引模式.一般而言, ...

  4. Cloudera CDH 、Impala本地通过Parcel安装配置详解

    一.Parcel本地源与Package本地源的区别 本地通过Parcel安装过程与本地通过Package安装过程完全一致,不同的是两者的本地源的配置. 区别如下: Package本地源:软件包是.rp ...

  5. .net web弹出对话框

    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入 ...

  6. android 学习随笔二十九(自定义监听 )

    package com.itheima.momo.dialog; import com.itheima.momo.R; import android.app.AlertDialog; import a ...

  7. jenkins相关

    1. jenkins maven tomcat做持续集成的时候几个关键配置:http://my.oschina.net/congqian/blog/112782?fromerr=PmIDbLs5 2. ...

  8. Delphi中如何将 Exe 程序或其他资料打包在内,使用时再释放使用(转)

    1.生成一个rc文件,文件格式如下: rname exefile "test.exe" //rname是资源名称 //exefile是资源类型 //text.exe是资源 资源类型 ...

  9. 161107、spring异步调用,完美解决!

    项目中,用户抢单,下单需要向对方推送消息,但是加上推送就会造成抢单和下单性能降低,反应变慢,因为抢单下单动作跟推送部分是同步的,现在想改成异步推送. 在Java应用中,绝大多数情况下都是通过同步的方式 ...

  10. Unicode : RLO

    分类:备忘,Unicode,Perl 我们一般的输入文字的方向是从左往右,但是世界上总有特例,阿拉伯国家是从右到左的书写方式.经常看到微信里面好友得瑟,也就拿过来总结一下. 每个语言都能实现字符串反转 ...