結果

問題 No.800 四平方定理
ユーザー koi_kotyakoi_kotya
提出日時 2019-03-18 18:29:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 3,058 ms
コンパイル使用メモリ 165,844 KB
実行使用メモリ 65,496 KB
最終ジャッジ日時 2023-09-25 16:58:36
合計ジャッジ時間 4,111 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 4 ms
5,816 KB
testcase_09 AC 3 ms
4,492 KB
testcase_10 AC 34 ms
34,092 KB
testcase_11 AC 38 ms
37,928 KB
testcase_12 AC 40 ms
37,068 KB
testcase_13 AC 34 ms
35,344 KB
testcase_14 AC 37 ms
37,916 KB
testcase_15 AC 40 ms
37,460 KB
testcase_16 AC 38 ms
38,132 KB
testcase_17 AC 38 ms
38,236 KB
testcase_18 AC 41 ms
38,364 KB
testcase_19 AC 41 ms
38,288 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 44 ms
38,136 KB
testcase_23 AC 91 ms
65,496 KB
testcase_24 AC 83 ms
65,472 KB
testcase_25 AC 88 ms
65,128 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 7 ms
10,876 KB
testcase_28 AC 82 ms
65,272 KB
testcase_29 AC 83 ms
65,276 KB
testcase_30 AC 82 ms
65,220 KB
testcase_31 AC 74 ms
60,984 KB
testcase_32 AC 86 ms
65,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,d;
    cin >> n >> d;
    int m = max(2*n*n+1,n*n+d+1);
    vector<int> a(m,0),b(m,0);
    for (int i = 1;i <= n;++i) for (int j = 1;j <= n;++j) a[i*i+j*j]++;
    for (int i = 1;i <= n;++i) for (int j = 1;j <= n;++j) if (i*i-j*j+d > 0) b[i*i-j*j+d]++;
    ll ans = 0;
    for (int i = 1;i < m;++i) ans += a[i]*b[i];
    cout << ans << endl;
    return 0;
}
0