結果
問題 |
No.639 An Ordinary Sequence
|
ユーザー |
![]() |
提出日時 | 2019-08-25 17:31:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 720 bytes |
コンパイル時間 | 1,450 ms |
コンパイル使用メモリ | 166,600 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-02 02:45:59 |
合計ジャッジ時間 | 2,137 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 |
ソースコード
#include "bits/stdc++.h" #define ALL(obj) (obj).begin(),(obj).end() #define RALL(obj) (obj).rbegin(),(obj).rend() #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define REPR(i, n) for(int i = (int)(n); i >= 0; i--) #define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++) using namespace std; typedef long long ll; const int MOD = 1e9 + 7; const int INF = MOD - 1; const ll LLINF = 4e18; ll solve(ll n, map<ll, ll> &m) { if (n == 0) { return 1; } if (m.find(n) != m.end()) { return m[n]; } else { return m[n] = solve(n / 3, m) + solve(n / 5, m); } } int main() { ll n; cin >> n; map<ll, ll> mp; cout << solve(n, mp) << endl; getchar(); getchar(); }