結果

問題 No.639 An Ordinary Sequence
ユーザー とばり
提出日時 2018-09-07 17:43:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 463 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 167,736 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-02 02:36:46
合計ジャッジ時間 2,615 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using int64 = long long;
using uint64 = unsigned long long;

map<int64, int64> memo;

int64 a(int64 n)
{
    if (memo.count(n) > 0)
    {
        return memo[n];
    }
    else if (n == 0)
    {
        return memo[n] = 1;
    }
    return (memo[n] = a(n / 3) + a(n / 5));
}

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

    int64 N;
    cin >> N;

    cout << a(N) << endl;

    return 0;
}
0