HDOJ-参考代码-(HDUACM2010版_14)Hash及应用

时间:2021-04-23 17:20:17
【文件属性】:
文件名称:HDOJ-参考代码-(HDUACM2010版_14)Hash及应用
文件大小:313KB
文件格式:PPT
更新时间:2021-04-23 17:20:17
杭电acm课件 acm HDOJ-1496参考代码(1) // by linle #include "stdio.h" #include "memory.h" int pin[101]; int hash[2000003]; int main() { int a,b,c,d; int i,j,sum; for(i=1;i<101;i++) pin[i] = i*i; while(scanf("%d %d %d %d",&a,&b,&c,&d)!=EOF) { …… } } if( (a>0 && b>0 && c>0 && d>0 )|| (a<0 && b<0 && c<0 && d<0) ) { printf("0\n"); continue; } memset(hash,0,sizeof(hash)); for(i=1;i<=100;i++) for(j=1;j<=100;j++) hash[a * pin[i] + b * pin[j] + 1000000]++; sum = 0; for(i=1;i<=100;i++) for(j=1;j<=100;j++) sum += hash[-(c * pin[i] + d * pin[j]) + 1000000]; printf("%d\n",sum*16);

网友评论