結果

問題 No.800 四平方定理
ユーザー betrue12betrue12
提出日時 2019-03-17 21:26:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 417 bytes
コンパイル時間 2,251 ms
コンパイル使用メモリ 206,444 KB
実行使用メモリ 9,480 KB
最終ジャッジ日時 2023-09-22 03:34:32
合計ジャッジ時間 6,374 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
9,480 KB
testcase_01 AC 38 ms
6,748 KB
testcase_02 AC 25 ms
5,652 KB
testcase_03 AC 28 ms
5,960 KB
testcase_04 AC 27 ms
5,464 KB
testcase_05 AC 31 ms
5,768 KB
testcase_06 AC 58 ms
7,340 KB
testcase_07 AC 39 ms
6,232 KB
testcase_08 AC 51 ms
7,064 KB
testcase_09 AC 44 ms
6,640 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, D;
    cin >> N >> D;
    map<int, int> mp1, mp2;
    for(int i=1; i<=N; i++) for(int j=1; j<=N; j++){
        mp1[i*i+j*j]++;
        mp2[i*i-j*j]++;
    }

    int64_t ans = 0;
    for(auto& p : mp2){
        int X = p.first;
        int Y = D-X;
        if(mp1.count(Y)) ans += p.second * mp1[Y];
    }
    cout << ans << endl;
    return 0;
}
0