POJ 1840 Eqs
来源:互联网 发布:中山 知乎 编辑:程序博客网 时间:2024/05/16 13:42
对a1x1^3+a2x2^3+a3x3^3的结果哈希, 然后暴力枚举x4, x5, 在哈希表中二分查找即可
/*author: birdstorm*/#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 <iostream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstdlib>#include <cctype>#include <string>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <ctime>#define MAXN 1005#define N 205#define INF 1<<30#define eps 1.0e-10#define For(i,m,n) for(i=(m);i<n;i++)using namespace std;vector<int> hash;int main(){ int i, j, k, sum, ans=0, cnt=0; int a, b, c, d, e; scanf("%d%d%d%d%d",&a,&b,&c,&d,&e); For(i,-50,51){ if(i==0) continue; For(j,-50,51){ if(j==0) continue; For(k,-50,51){ if(k==0) continue; sum=i*i*i*a+j*j*j*b+k*k*k*c; hash.push_back(sum); } } } sort(hash.begin(),hash.end()); For(i,-50,51){ if(i==0) continue; For(j,-50,51){ if(j==0) continue; sum=-i*i*i*d-j*j*j*e; if(binary_search(hash.begin(),hash.end(),sum)) ans+=upper_bound(hash.begin(),hash.end(),sum)-lower_bound(hash.begin(),hash.end(),sum); } } printf("%d\n",ans); return 0;}
0 0
- poj 1840 Eqs
- POJ 1840 Eqs
- poj 1840 Eqs
- POJ 1840 Eqs
- POJ 1840 Eqs hash
- POJ-1840 Eqs【Hash】
- poj 1840 Eqs 【hash】
- POJ 1840 Eqs
- poj-1840 Eqs
- POJ 1840 Eqs
- POJ 1840 Eqs
- poj 1840 Eqs
- POJ 1840 Eqs
- POJ 1840 Eqs
- POJ 1840(Eqs)
- POJ 1840 Eqs
- POJ 1840 Eqs
- POJ 1840 Eqs
- python3.3.2中的关键字分析
- Windows下安装Hadoop
- [OpenStack Nova] ephemeral disk & root disk & swap disk
- QT---线程间通信
- 抽像工厂模式
- POJ 1840 Eqs
- Xbox宣布正式登陆中国 今年9月开售
- PB6.5调用Web Service的办法
- 3D打印产品/3D打印机和2D定制产品/2D数码设备的资讯大全
- Linux 各个版本之间的差别
- PL/SQL设置NUMBER显示为字符串
- 孕期撒变大是你进口车男方家的年上返回啊内窥镜打撒
- apt-get 出现Encountered a section with no Package: header的解决办法
- PB与各种数据库连接