結果

問題 No.800 四平方定理
ユーザー nebukuro09nebukuro09
提出日時 2019-04-18 05:13:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 580 bytes
コンパイル時間 3,560 ms
コンパイル使用メモリ 174,088 KB
実行使用メモリ 88,176 KB
最終ジャッジ日時 2023-10-22 07:39:56
合計ジャッジ時間 38,236 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,348 KB
testcase_01 AC 13 ms
4,920 KB
testcase_02 AC 9 ms
4,604 KB
testcase_03 AC 10 ms
4,668 KB
testcase_04 AC 9 ms
4,504 KB
testcase_05 AC 10 ms
4,636 KB
testcase_06 AC 15 ms
5,660 KB
testcase_07 AC 11 ms
4,868 KB
testcase_08 AC 16 ms
5,660 KB
testcase_09 AC 13 ms
5,660 KB
testcase_10 AC 1,053 ms
45,652 KB
testcase_11 AC 1,173 ms
49,612 KB
testcase_12 AC 1,153 ms
48,820 KB
testcase_13 AC 1,172 ms
47,236 KB
testcase_14 AC 1,263 ms
49,612 KB
testcase_15 AC 1,270 ms
49,348 KB
testcase_16 AC 1,304 ms
49,876 KB
testcase_17 AC 1,317 ms
49,876 KB
testcase_18 AC 1,221 ms
49,612 KB
testcase_19 AC 1,227 ms
49,876 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 1,309 ms
49,876 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ll N, D;

void solve() {
    cin >> N >> D;

    unordered_map<ll, ll> cnt;
    REP2 (z, 1, N+1) REP2 (w, 1, N+1) cnt[z*z-w*w] += 1;
    ll ans = 0;

    REP2 (x, 1, N+1) {
        REP2 (y, 1, N+1) {
            if (cnt.find(D-x*x-y*y) != cnt.end()) {
                ans += cnt[D-x*x-y*y];
            }
        }
    }

    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0