HDU 1496 (水题)

题目链接:点击打开链接

窝真是个傻逼.直接把第三第四种的数字的组合存下来直接找就好了.

#include 
#include 
#include 
#include 
#include 
using namespace std;
#define maxn 11111
#define add 1000000

int a, b, c, d;
int num1[maxn], cnt1;
int num2[2000005];

int main () {
    while (scanf ("%d%d%d%d", &a, &b, &c, &d) == 4) {
        cnt1 = 0;
        memset (num2, 0, sizeof num2);
        for (int i = 1; i <= 100; i++) {
            for (int j = 1; j <= 100; j++) {
                num1[cnt1++] = a*i*i+b*j*j;
                num2[c*i*i+d*j*j+add] += 4;
            }
        }
        long long ans = 0;
        for (int i = 0; i < cnt1; i++) {
            int need = -1*num1[i];
            ans += 1LL*4*num2[need+add];
        }
        printf ("%lld\n", ans);
    }
    return 0;
}


你可能感兴趣的:(水题)