結果

問題 No.800 四平方定理
ユーザー kakira9618kakira9618
提出日時 2019-03-18 00:04:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 59,340 KB
実行使用メモリ 65,800 KB
最終ジャッジ日時 2023-09-22 16:10:35
合計ジャッジ時間 3,595 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
65,580 KB
testcase_01 AC 31 ms
65,644 KB
testcase_02 AC 31 ms
65,772 KB
testcase_03 AC 31 ms
65,520 KB
testcase_04 AC 32 ms
65,800 KB
testcase_05 AC 32 ms
65,548 KB
testcase_06 AC 31 ms
65,576 KB
testcase_07 AC 31 ms
65,544 KB
testcase_08 AC 32 ms
65,428 KB
testcase_09 AC 31 ms
65,492 KB
testcase_10 AC 59 ms
65,436 KB
testcase_11 AC 62 ms
65,560 KB
testcase_12 AC 63 ms
65,496 KB
testcase_13 AC 56 ms
65,580 KB
testcase_14 AC 57 ms
65,744 KB
testcase_15 AC 64 ms
65,496 KB
testcase_16 AC 57 ms
65,500 KB
testcase_17 AC 59 ms
65,496 KB
testcase_18 AC 68 ms
65,492 KB
testcase_19 AC 70 ms
65,520 KB
testcase_20 AC 30 ms
65,476 KB
testcase_21 AC 30 ms
65,492 KB
testcase_22 AC 68 ms
65,664 KB
testcase_23 AC 101 ms
65,600 KB
testcase_24 AC 88 ms
65,576 KB
testcase_25 AC 101 ms
65,576 KB
testcase_26 AC 31 ms
65,492 KB
testcase_27 AC 31 ms
65,472 KB
testcase_28 AC 86 ms
65,532 KB
testcase_29 AC 96 ms
65,488 KB
testcase_30 AC 88 ms
65,660 KB
testcase_31 AC 85 ms
65,584 KB
testcase_32 AC 92 ms
65,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
    int N, D;
    cin >> N >> D;
    vector<int> cnt1(2 * 2000 * 2000 + 1);
    vector<int> cnt2(2 * 2000 * 2000 + 1);
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            cnt1[i * i + j * j]++;
            if (i * i - j * j + D >= 0 && i * i - j * j + D < cnt2.size()) cnt2[i * i - j * j + D]++;
        }
    }
    
    ll ans = 0;
    for(int i = 0; i < cnt1.size(); i++) {
        ans += cnt1[i] * cnt2[i];
    }
    cout << ans << endl;
    
    return 0;
}
0