poj 1840
来源:互联网 发布:孕囊第三个数据最大 编辑:程序博客网 时间:2024/06/05 04:15
求出两项的和,跟后三项比较
用int只能开数组开到12500000内存达到49000,可以用
用short 省一半内存
#include<stdio.h>#include<string.h>short mark1[12500001];int main(){int a[10005];int b[5];int i,j;j=0;int temp;for(i=-50;i<=50;i++){if(i==0)continue;a[j]=i*i*i;j++;}while(scanf("%d%d%d%d%d",&b[0],&b[1],&b[2],&b[3],&b[4])!=EOF){memset(mark1,0,sizeof(mark1));int q,w,e,r,t,i,j;for(i=0;i<100;i++){if(!a[i])continue;for(j=0;j<100;j++){if(!a[j])continue;temp=a[i]*b[3]+a[j]*b[4];if(temp<0)mark1[-1*temp]++;else if(temp>0)mark1[temp]++;else mark1[temp]+=2;}}__int64 ans=0;int temp;for(q=0;q<100;q++){for(w=0;w<100;w++)for(e=0;e<100;e++){temp=b[0]*a[q]+b[1]*a[w]+b[2]*a[e];if(temp>12500000||temp<=-12500000)continue;//前两项的区间是[-12500000,12500000],//三项的和最大达到18750000;if(temp<=0){temp=-1*temp;ans+=mark1[temp];}else ans+=mark1[temp];}}printf("%I64d\n",ans/2);}return 0;}
- POJ 1840
- POJ 1840
- POJ 1840
- POJ 1840
- poj 1840
- poj-1840
- POJ 1840
- poj 1840
- Poj 1840
- POJ 1840
- poj 1840
- poj 1840
- poj 1840 Eqs
- POJ 1840 Eqs
- POJ 1840 (哈希)
- poj 1840 Eqs
- POJ 1840 Eqs
- poj 1840 简单hash。
- H - Happy Programming Contest
- google是怎样工作的
- HDU 1232 畅通工程
- UVa 532Dungeon Master
- ThinkPHP3.1快速入门连贯操作
- poj 1840
- 简单快速打印100以内的素数
- Android程序调试时生成main.out.xml文件
- 万能js实现翻页,兼容各种浏览器(已测试)----屌丝版!
- 数据库中,如何通过表名获取表的字段名(属性名)?
- WebBrowser 在多线程中,无法释放内存
- 深度探析如何提高Web表单的可用性
- Tornado的初步了解
- 【转】让你提升命令行效率的 Bash 快捷键