結果

問題 No.800 四平方定理
ユーザー r1825r1825
提出日時 2019-03-17 21:33:59
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 1,280 ms
使用メモリ 34,300 KB
最終ジャッジ日時 2023-02-11 04:40:02
合計ジャッジ時間 3,167 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,992 KB
testcase_01 AC 2 ms
4,148 KB
testcase_02 AC 2 ms
3,972 KB
testcase_03 AC 2 ms
4,116 KB
testcase_04 AC 1 ms
4,044 KB
testcase_05 AC 2 ms
4,120 KB
testcase_06 AC 2 ms
4,300 KB
testcase_07 AC 2 ms
4,096 KB
testcase_08 AC 2 ms
4,300 KB
testcase_09 AC 1 ms
4,180 KB
testcase_10 AC 14 ms
18,840 KB
testcase_11 AC 14 ms
20,640 KB
testcase_12 AC 14 ms
20,440 KB
testcase_13 AC 13 ms
19,508 KB
testcase_14 AC 14 ms
20,712 KB
testcase_15 AC 16 ms
20,620 KB
testcase_16 AC 14 ms
20,832 KB
testcase_17 AC 14 ms
20,872 KB
testcase_18 AC 16 ms
20,760 KB
testcase_19 AC 16 ms
20,872 KB
testcase_20 AC 2 ms
3,664 KB
testcase_21 AC 1 ms
3,608 KB
testcase_22 AC 17 ms
20,936 KB
testcase_23 AC 37 ms
34,268 KB
testcase_24 AC 35 ms
34,236 KB
testcase_25 AC 38 ms
34,124 KB
testcase_26 AC 1 ms
3,652 KB
testcase_27 AC 2 ms
3,568 KB
testcase_28 AC 35 ms
34,084 KB
testcase_29 AC 35 ms
34,200 KB
testcase_30 AC 35 ms
34,116 KB
testcase_31 AC 32 ms
32,076 KB
testcase_32 AC 37 ms
34,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int flg[2001*2001*2];
int ans;

signed main () {

    int n, d;
    scanf("%d %d", &n, &d);
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 1; j <= n; j++ ) {
            flg[i*i+j*j]++;
        }
    }
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 1; j <= n; j++ ) {
            if ( j*j+d-i*i < 0 ) continue;
            ans += flg[j*j+d-i*i];
        }
    }
    printf("%d\n", ans);


    return 0;
}
0