結果

問題 No.639 An Ordinary Sequence
ユーザー Rubikun
提出日時 2019-08-05 16:09:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 452 bytes
コンパイル時間 1,675 ms
コンパイル使用メモリ 169,888 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-02 02:50:34
合計ジャッジ時間 2,496 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;
map<ll,ll> MP;

ll solve(ll a){
    
    if(a==0) return MP[0]=1;
    
    ll ans=0;
    
    if(MP[a/3]) ans+=MP[a/3];
    else ans+=solve(a/3);
    if(MP[a/5]) ans+=MP[a/5];
    else ans+=solve(a/5);
    
    return MP[a]=ans;
}

int main(){

    ll N;cin>>N;
    
    cout<<solve(N)<<endl;
    
}
0