結果

問題 No.152 貯金箱の消失
ユーザー Mister
提出日時 2020-04-22 11:13:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 416 ms / 5,000 ms
コード長 564 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 67,164 KB
最終ジャッジ日時 2025-01-09 22:27:35
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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