結果

問題 No.800 四平方定理
ユーザー ugis_progugis_prog
提出日時 2019-03-17 22:42:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 62,656 KB
実行使用メモリ 34,352 KB
最終ジャッジ日時 2023-09-22 08:42:34
合計ジャッジ時間 2,553 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,500 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 20 ms
18,376 KB
testcase_11 AC 23 ms
20,416 KB
testcase_12 AC 25 ms
20,348 KB
testcase_13 AC 23 ms
19,272 KB
testcase_14 AC 23 ms
20,416 KB
testcase_15 AC 25 ms
20,184 KB
testcase_16 AC 23 ms
20,476 KB
testcase_17 AC 23 ms
20,720 KB
testcase_18 AC 26 ms
20,560 KB
testcase_19 AC 24 ms
20,348 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 25 ms
20,564 KB
testcase_23 AC 66 ms
34,352 KB
testcase_24 AC 58 ms
34,124 KB
testcase_25 AC 66 ms
34,344 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 61 ms
33,960 KB
testcase_29 AC 65 ms
34,244 KB
testcase_30 AC 62 ms
33,928 KB
testcase_31 AC 56 ms
31,920 KB
testcase_32 AC 63 ms
34,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    long N,D;
    cin >> N >> D;
    vector<int> sq(2*N*N+1,0);

    for(int y=1;y<=N;y++){
        for(int z=1;z<=N;z++){
            sq[y*y+z*z]++;
        }
    }

    long ans = 0;
    for(long x=1;x<=N;x++){
        for(long w=1;w<=N;w++){
            long c = w*w - x*x + D;
            if(c < 2 || c > 2*N*N) continue;
            ans += sq[c];
        }
    }
    cout << ans << endl;
}
0