poj1840
来源:互联网 发布:看图编辑软件 编辑:程序博客网 时间:2024/05/22 10:38
#include <iostream>#include <string.h>using namespace std;short hash[37500001];int main(){memset(hash,0,sizeof(hash));int a1,a2,a3,a4,a5;int sum,sum1;while(cin>>a1>>a2>>a3>>a4>>a5){for(int x1=-50;x1<=50;x1++){if(!x1)continue;for(int x2=-50;x2<=50;x2++){if(!x2)continue;sum=(a1*x1*x1*x1+a2*x2*x2*x2);sum+=18750000;//sum=(a1*x1*x1*x1 + a2*x2*x2*x2)*(-1); // if(sum<0) // sum+=25000000; hash[sum]++;}}int sol=0;for(int x3=-50;x3<=50;x3++){if(!x3)continue;for (int x4=-50;x4<=50;x4++){if(!x4)continue;for (int x5=-50;x5<=50;x5++){if(!x5)continue;sum1=(a3*x3*x3*x3+a4*x4*x4*x4+a5*x5*x5*x5)*(-1);sum1+=18750000;//sum1=a3*x3*x3*x3 + a4*x4*x4*x4 + a5*x5*x5*x5; //if(sum1<0) // sum1+=25000000; if(hash[sum1])sol+=hash[sum1];}}}cout<<sol<<endl;}return 0;}原来网上代码数组是开25000000的,但是这样在第二个FOR循环sum会冲突啊 改成37500000就MLE了 我也不懂为什么可以只开25000000的
0 0
- poj1840
- poj1840
- POJ1840
- poj1840
- POJ1840
- poj1840
- poj1840
- poj1840
- poj1840
- poj1840
- poj1840
- poj1840
- POJ1840
- poj1840--Eqs
- poj1840 Eqs
- poj1840 Eqs
- POJ1840 哈希表
- Eqs poj1840
- Topcoder SRM 636 div2 1000
- LeetCode::Reorder List
- ssh框架包的作用【转】
- 人脸检测-Haar分类器方法
- android - anim translate中 fromXDelta、toXDelta、fromYDelta、toXDelta属性
- poj1840
- Maven2的配置文件settings.xml
- Linux-Backup
- OC中description和SEL
- win7环境下visualsvn-server的搭建与使用(Eclipse)整合版
- cf476D构造
- 程序语言的底层描述(5)——数组、指针的汇编实现以及C程序嵌入汇编
- gggggggggggg
- HDU 1729