結果

問題 No.800 四平方定理
ユーザー kyort0nkyort0n
提出日時 2019-03-17 21:26:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 1,482 ms
コンパイル使用メモリ 164,052 KB
実行使用メモリ 67,104 KB
最終ジャッジ日時 2023-09-22 03:34:25
合計ジャッジ時間 4,128 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,680 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,384 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 2 ms
4,468 KB
testcase_06 AC 3 ms
4,920 KB
testcase_07 AC 3 ms
4,484 KB
testcase_08 AC 4 ms
4,756 KB
testcase_09 AC 3 ms
4,700 KB
testcase_10 AC 43 ms
36,164 KB
testcase_11 AC 47 ms
38,276 KB
testcase_12 AC 46 ms
38,168 KB
testcase_13 AC 41 ms
36,116 KB
testcase_14 AC 51 ms
38,164 KB
testcase_15 AC 48 ms
38,160 KB
testcase_16 AC 45 ms
40,264 KB
testcase_17 AC 45 ms
40,460 KB
testcase_18 AC 53 ms
40,268 KB
testcase_19 AC 51 ms
40,320 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 52 ms
40,344 KB
testcase_23 AC 102 ms
66,884 KB
testcase_24 AC 92 ms
66,836 KB
testcase_25 AC 99 ms
67,104 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 92 ms
66,880 KB
testcase_29 AC 95 ms
66,848 KB
testcase_30 AC 92 ms
67,100 KB
testcase_31 AC 82 ms
62,800 KB
testcase_32 AC 93 ms
66,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, D;
ll to[10000000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> D;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            int ans = i * i + j * j;
            to[ans]++;
        }
    }
    ll ans = 0;
    for(ll x = 1; x <= N; x++) {
        for(ll w = 1; w <= N; w++) {
            ll tmp = D + w * w - x * x;
            if(tmp > 0) ans += to[tmp];
        }
    }
    cout << ans << endl;
    return 0;
}
0