結果

問題 No.639 An Ordinary Sequence
ユーザー Mister
提出日時 2020-08-01 23:13:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 443 bytes
コンパイル時間 1,613 ms
コンパイル使用メモリ 76,012 KB
最終ジャッジ日時 2025-01-12 12:55:43
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>

using lint = long long;

lint dfs(lint n) {
    static std::map<lint, lint> dp;
    if (dp.count(n)) return dp[n];

    auto& ret = dp[n];
    if (n == 0) return ret = 1;
    return ret = dfs(n / 3) + dfs(n / 5);
}

void solve() {
    lint n;
    std::cin >> n;
    std::cout << dfs(n) << "\n";
}

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

    solve();

    return 0;
}
0