HDU 1496 Equations

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1496


#include <cstdio>
#include <cstring>

int hash[2001000], p[101];

int main( )
{
    int a, b, c, d;
    for(int i=1; i<101; i++) p[i] = i*i;
    while(~scanf("%d%d%d%d", &a, &b, &c, &d)) {
        int sum = 0;
        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(int i=1; i<=100; i++)
            for(int j=1; j<=100; j++)
                hash[a*p[i] + b*p[j] + 1000000]++;
        for(int i=1; i<=100; i++)
            for(int j=1; j <= 100; j ++)
                sum += hash[1000000 - c*p[i] - d*p[j]];
        printf("%d\n", sum<<4);
    }
    return 0;
}


發佈了40 篇原創文章 · 獲贊 4 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章