a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0
对于这个等式,给出了a1到a5,最后求有多少组X1---X5满足这个等式,其中所有的Xi都是不能等于0的。
然后每个Xi的范围是-50到50。这个数据范围是能hash的保证。
分成两组,前3个X是一组,后两个一组。
/*
ID: sdj22251
PROG:
LANG: C++
*/
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#define MAXN 111111
#define MAXM 104444
#define INF 100000000
#define PI acos(-1.0)
#define eps 1e-12
#define L(X) X<<1
#define R(X) X<<1|1
using namespace std;
char hash[25000005];
int a[6];
int main()
{
memset(hash, 0, sizeof(hash));
for(int i = 0; i < 5; i++) scanf("%d", &a[i]);
for(int i = -50; i <= 50; i++)
{
if(i == 0) continue;
for(int j = -50; j <= 50; j++)
{
if(j == 0) continue;
for(int k = -50; k <= 50; k++)
{
if(k == 0) continue;
int tmp = i * i * i * a[0] + j * j * j * a[1] + k * k * k * a[2];
if(tmp > 12500000 || tmp < -12500000)
continue;
hash[tmp + 12500000]++;
}
}
}
int ans = 0;
for(int i = -50; i <= 50; i++)
{
if(i == 0) continue;
for(int j = -50; j <= 50; j++)
{
if(j == 0) continue;
int tmp = -(i * i * i * a[3] + j * j * j * a[4]);
ans += hash[tmp + 12500000];
}
}
printf("%d\n", ans);
return 0;
}
分享到:
相关推荐
北大POJ1840-Eqs 解题报告+AC代码
北大POJ初级-简单搜索 解题报告+AC代码
POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类
poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题...
POJ第1861题源码 POJ第1861题源码 POJ第1861题源码
poj分类poj分类poj分类poj分类
北大POJ1159-Palindrome 解题报告+AC代码
poj 3414解题报告poj 3414解题报告poj 3414解题报告poj 3414解题报告
poj 1012解题报告poj 1012解题报告poj 1012解题报告poj 1012解题报告
poj 2329解题报告poj 2329解题报告poj 2329解题报告poj 2329解题报告
poj 1659解题报告poj 1659解题报告poj 1659解题报告poj 1659解题报告
C语言 poj npu 西工大 C语言Poj答案全完整打包,给有需要的朋友
POJ1503解答 POJ1503解答,正确答案(已通过POJ)
poj 百练 题目分类 poj 百练 题目分类
POJ1083的代码,POJ1083的代码,POJ1083的代码
POJ1048,加强版的约瑟夫问题 难度中等
北大POJ2002-Squares 解题报告+AC代码
poj 1001答案
POJ2968代码有用,欢迎下载,POJ代码
poj 2744子串 答案 所用的是最简单的C语言