http://162.105.81.212/JudgeOnline/problem?id=1840 枚举+哈希 开个char hash[37500001]飘逸的水过去- - #include<iostream> using namespace std; #define MAX 37500001 #define ADD 18750000 char hash[MAX]; int main() { int i, j, k, a1, a2, a3, a4, a5, tmp, ret; while(scanf("%d%d%d%d%d", &a1, &a2, &a3, &a4, &a5) == 5) { ret = 0; memset(hash, 0, sizeof(hash)); for(i=-50; i<=50; i++) { if(!i) continue; for(j=-50; j<=50; j++) { if(!j) continue; for(k=-50; k<=50; k++) { if(!k) continue; tmp = a1*i*i*i + a2*j*j*j + a3*k*k*k; tmp += ADD; hash[tmp]++; } } } for(i=-50; i<=50; i++) { if(!i) continue; for(j=-50; j<=50; j++) { if(!j) continue; tmp = a4*i*i*i + a5*j*j*j; tmp = -tmp; tmp += ADD; if(hash[tmp]) ret += hash[tmp]; } } printf("%d/n", ret); } return 0; }