poj 1840 暴力+标记
Description
a1x1 3+ a2x2 3+ a3x3 3+ a4x4 3+ a5x5 3=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
Output
Sample Input
37 29 41 43 47
Sample Output
654 暴力+标记
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <map>
#include <stack>
#define inf 0xfffff
typedef long long ll;
using namespace std;
#define MAXN 25000000
#define mod 10007
#define eps 1e-9
short hash[];
int main()
{
int a1,a2,a3,a4,a5;
while(scanf("%d %d %d %d %d",&a1,&a2,&a3,&a4,&a5)!=EOF)
{
int sum=;
for(int i=-; i<=; i++)
for(int j=-; j<=; j++)
for(int k=-; k<=; k++)
{
if(i==||j==||k==)
continue;
if(a1*i*i*i+a2*j*j*j+a3*k*k*k<)
hash[a1*i*i*i+a2*j*j*j+a3*k*k*k+MAXN]++;
else
hash[a1*i*i*i+a2*j*j*j+a3*k*k*k]++;
} for(int i=-; i<=; i++)
for(int j=-; j<=; j++)
{
int u=-a4*i*i*i-a5*j*j*j;
if(u<)
u=u+MAXN;;
if(hash[u]&&i!=&&j!=)
{
sum+=hash[u];
}
}
printf("%d\n",sum);
}
return ;
}
poj 1840 暴力+标记的更多相关文章
- POJ 2182/暴力/BIT/线段树
POJ 2182 暴力 /* 题意: 一个带有权值[1,n]的序列,给出每个数的前面比该数小的数的个数,当然比一个数前面比第一个数小的个数是0,省略不写,求真正的序列.(拗口) 首先想到的是从前到后暴 ...
- POJ 1840 Eqs 暴力
Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The ...
- POJ 1840 Eqs 二分+map/hash
Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The co ...
- POJ 1840 HASH
题目链接:http://poj.org/problem?id=1840 题意:公式a1x1^3+ a2x2^3+ a3x3^3+ a4x4^3+ a5x5^3=0,现在给定a1~a5,求有多少个(x1 ...
- poj 1840 Eqs (hash)
题目:http://poj.org/problem?id=1840 题解:http://blog.csdn.net/lyy289065406/article/details/6647387 小优姐讲的 ...
- POJ 1840 Eps 解题报告(哈希)
a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0,xi∈[-50,50],且xi!=0.让我们求所有解的可能. 首先,如果暴力判断的话,每个x的取值有100种可能,100^5肯定 ...
- 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 Brainman(逆序对数)
题目链接:http://poj.org/problem?id=1804 题意:给定一个序列a[],每次只允许交换相邻两个数,最少要交换多少次才能把它变成非递降序列. 思路:题目就是要求逆序对数,我们知 ...
- POJ - 1426 暴力枚举+同余模定理 [kuangbin带你飞]专题一
完全想不到啊,同余模定理没学过啊,想起上学期期末考试我问好多同学'≡'这个符号什么意思,都说不知道,你们不是上了离散可的吗?不过看了别人的解法我现在会了,同余模定理介绍及运用点这里点击打开链接 简单说 ...
随机推荐
- js基础之事件
一.event对象 document.onclick=function(ev){ oEvent=event?event:ev;//兼容性写法 alert(oEvent.clientX); alert( ...
- POJ 1719 二分图最大匹配(记录路径)
Shooting Contest Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4097 Accepted: 1499 ...
- <转>提高iOS开发效率的方法和工具
介绍 这篇文章主要是介绍一下我在iOS开发中使用到的一些可以提升开发效率的方法和工具. IDE 首先要说的肯定是IDE了,说到IDE,Xcode不能跑,当然你也可能同时在使用AppCode等其他的ID ...
- Spring依赖关系
在Spring中,各个模块的依赖关系通过简单的IoC配置文件进行描述,使这些外部化的信息集中并且明了,我们在使用其他组件服务时,只需要去配置文件中了解和配置这些依赖关系即可,也就是说这里关心的是接口, ...
- Oracle Database 11g express edition
commands : show sys connect sys as sysdba or connect system as sysdba logout or disc clear screen or ...
- CSS网页布局:网站整体居中 转
body{ margin:0 auto; padding:0 auto; text-align:center;} 只设置body属性对ie浏览器有效果,但是对火狐等不起作用 body{ ...
- Apache虚拟目录(二)
一.PHP生命周期 二.轻量级的PHP 轻量级PHP产品由lighttpd,nginx等等 Apache是基于模块化设计的 了解Apache源代码可以从main.c开始 操作系统上跑了APR运行库 m ...
- iOS定时器NSTimer的使用方法
1.初始化 + (NSTimer *)timerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelect ...
- POJ 2752 - Seek the Name, Seek the Fame (KMP)
题意:给一个字符串s,问s的某个前缀与后缀相同的情况时,长度是多少. 此题使用KMP的next数组解决. next数组中,j=next[i],next[i]表示S[0...i-1]的某个后缀(字符串S ...
- error C3163: “_vsnprintf”: 属性与以前的声明不一致
这是在vs2008中遇到的错误,vs2008以前没有,vs2008以后的vs也没有. c:\program files\microsoft visual studio 9.0\vc\include\s ...