結果
問題 | No.639 An Ordinary Sequence |
ユーザー |
![]() |
提出日時 | 2018-01-26 23:52:44 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 22 ms / 1,000 ms |
コード長 | 766 bytes |
コンパイル時間 | 1,655 ms |
コンパイル使用メモリ | 157,900 KB |
実行使用メモリ | 7,672 KB |
最終ジャッジ日時 | 2025-01-02 02:09:53 |
合計ジャッジ時間 | 2,371 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 |
ソースコード
#include "bits/stdc++.h"using namespace std;using ll = long long; using pii = pair<int, int>;const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)#define rep(i,n) FOR(i,0,n)template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }ll dp[500000];ll f(ll x) {if (x < 500000) {ll &r = dp[x];if (r != -1) return r;}if (x == 0) return 1;return f(x / 3) + f(x / 5);}int main() {ll n; cin >> n;memset(dp, -1, sizeof(dp));dp[0] = 1;FOR(i, 1, 500000) dp[i] = dp[i / 3] + dp[i / 5];cout << f(n) << "\n";return 0;}