結果

問題 No.800 四平方定理
ユーザー rogi52rogi52
提出日時 2022-08-13 13:58:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 2,456 ms
コンパイル使用メモリ 201,972 KB
実行使用メモリ 65,712 KB
最終ジャッジ日時 2023-10-24 22:18:17
合計ジャッジ時間 5,019 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 4 ms
4,516 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 4 ms
4,516 KB
testcase_09 AC 3 ms
4,516 KB
testcase_10 AC 62 ms
34,204 KB
testcase_11 AC 76 ms
38,044 KB
testcase_12 AC 75 ms
37,292 KB
testcase_13 AC 68 ms
35,512 KB
testcase_14 AC 74 ms
38,044 KB
testcase_15 AC 73 ms
37,780 KB
testcase_16 AC 72 ms
38,308 KB
testcase_17 AC 75 ms
38,308 KB
testcase_18 AC 73 ms
38,308 KB
testcase_19 AC 73 ms
38,308 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 79 ms
38,308 KB
testcase_23 AC 142 ms
65,712 KB
testcase_24 AC 147 ms
65,620 KB
testcase_25 AC 156 ms
65,424 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 147 ms
65,424 KB
testcase_29 AC 147 ms
65,552 KB
testcase_30 AC 149 ms
65,448 KB
testcase_31 AC 135 ms
61,064 KB
testcase_32 AC 150 ms
65,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N,D; cin >> N >> D;
    int M = 2 * N * N;
    vector<int> a(M + 1, 0), b(M + 1, 0);
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= N; j++)
            a[i * i + j * j]++, b[i * i - j * j + N * N]++;
    
    int ans = 0;
    for(int i = 1; i <= M; i++) {
        int x = i - D + N * N;
        if(0 <= x && x <= M) ans += a[i] * b[x];
    }
    cout << ans << endl;
}
0