結果

問題 No.800 四平方定理
ユーザー kyort0nkyort0n
提出日時 2019-03-17 21:26:50
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 1,663 ms
使用メモリ 64,512 KB
最終ジャッジ日時 2023-02-11 03:54:06
合計ジャッジ時間 3,736 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
6,948 KB
testcase_01 AC 2 ms
6,948 KB
testcase_02 AC 2 ms
6,948 KB
testcase_03 AC 2 ms
4,904 KB
testcase_04 AC 2 ms
4,900 KB
testcase_05 AC 2 ms
4,904 KB
testcase_06 AC 2 ms
6,948 KB
testcase_07 AC 2 ms
4,904 KB
testcase_08 AC 3 ms
4,904 KB
testcase_09 AC 2 ms
4,900 KB
testcase_10 AC 25 ms
33,520 KB
testcase_11 AC 31 ms
37,356 KB
testcase_12 AC 29 ms
36,700 KB
testcase_13 AC 25 ms
35,032 KB
testcase_14 AC 28 ms
37,352 KB
testcase_15 AC 33 ms
37,160 KB
testcase_16 AC 31 ms
37,828 KB
testcase_17 AC 33 ms
37,804 KB
testcase_18 AC 37 ms
37,520 KB
testcase_19 AC 34 ms
37,568 KB
testcase_20 AC 1 ms
4,904 KB
testcase_21 AC 1 ms
4,904 KB
testcase_22 AC 34 ms
37,760 KB
testcase_23 AC 89 ms
64,500 KB
testcase_24 AC 86 ms
64,412 KB
testcase_25 AC 92 ms
64,376 KB
testcase_26 AC 1 ms
4,904 KB
testcase_27 AC 1 ms
4,900 KB
testcase_28 AC 84 ms
64,196 KB
testcase_29 AC 81 ms
64,408 KB
testcase_30 AC 80 ms
64,260 KB
testcase_31 AC 72 ms
60,024 KB
testcase_32 AC 82 ms
64,512 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