結果

問題 No.800 四平方定理
ユーザー pppppppoipoipppppppoipoi
提出日時 2019-04-16 23:18:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 593 ms
コンパイル使用メモリ 69,212 KB
実行使用メモリ 65,868 KB
最終ジャッジ日時 2023-10-22 07:14:52
合計ジャッジ時間 3,066 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
65,848 KB
testcase_01 AC 21 ms
65,848 KB
testcase_02 AC 21 ms
65,848 KB
testcase_03 AC 21 ms
65,848 KB
testcase_04 AC 25 ms
65,848 KB
testcase_05 AC 20 ms
65,848 KB
testcase_06 AC 21 ms
65,848 KB
testcase_07 AC 21 ms
65,848 KB
testcase_08 AC 22 ms
65,848 KB
testcase_09 AC 21 ms
65,848 KB
testcase_10 AC 43 ms
65,832 KB
testcase_11 AC 44 ms
65,868 KB
testcase_12 AC 45 ms
65,868 KB
testcase_13 AC 42 ms
65,868 KB
testcase_14 AC 46 ms
65,868 KB
testcase_15 AC 48 ms
65,868 KB
testcase_16 AC 45 ms
65,868 KB
testcase_17 AC 47 ms
65,868 KB
testcase_18 AC 51 ms
65,868 KB
testcase_19 AC 51 ms
65,868 KB
testcase_20 AC 21 ms
65,868 KB
testcase_21 AC 20 ms
65,868 KB
testcase_22 AC 50 ms
65,868 KB
testcase_23 AC 91 ms
65,868 KB
testcase_24 AC 86 ms
65,868 KB
testcase_25 AC 88 ms
65,868 KB
testcase_26 AC 20 ms
65,868 KB
testcase_27 AC 20 ms
65,868 KB
testcase_28 AC 87 ms
65,868 KB
testcase_29 AC 88 ms
65,868 KB
testcase_30 AC 85 ms
65,868 KB
testcase_31 AC 79 ms
65,868 KB
testcase_32 AC 85 ms
65,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,d,ans = 0;
    cin >> n >> d;
    vector<int> a(2*2000*2000+10),b(2*2000*2000+10);
    
    for(int x = 1;x <= n;x++){
        for(int y = 1;y <= n;y++){
            a[x*x+y*y]++;
        }
    }
    
    for(int w = 1;w <= n;w++){
        for(int z = 1;z <= n;z++){
            if(w*w-z*z+d < 0 || w*w-z*z+d > 2*n*n) continue;
            b[w*w-z*z+d]++;
        }
    }
    for(int i = 1;i <= 2*n*n;i++){
        ans += a[i]*b[i];
    }
    cout << ans << endl;
}
0