結果

問題 No.152 貯金箱の消失
ユーザー MisterMister
提出日時 2020-04-22 11:13:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 428 ms / 5,000 ms
コード長 564 bytes
コンパイル時間 710 ms
コンパイル使用メモリ 71,416 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 10:26:23
合計ジャッジ時間 2,792 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 7 ms
5,376 KB
testcase_05 AC 7 ms
5,376 KB
testcase_06 AC 11 ms
5,376 KB
testcase_07 AC 59 ms
5,376 KB
testcase_08 AC 395 ms
5,376 KB
testcase_09 AC 428 ms
5,376 KB
testcase_10 AC 311 ms
5,376 KB
testcase_11 AC 165 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <numeric>

constexpr int MOD = 1000003;

void solve() {
    int l;
    std::cin >> l;

    int ans = 0;
    for (int m = 1; m * m <= l; ++m) {
        for (int n = 1; n < m; ++n) {
            int a = m * m - n * n,
                b = m * n * 2;
            if (std::gcd(a, b) != 1) continue;

            int sum = m * 2 * (m + n);
            if (sum * 4 <= l) ++ans;
        }
    }

    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0