結果
問題 | No.639 An Ordinary Sequence |
ユーザー | fushime2 |
提出日時 | 2018-01-26 23:52:44 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 23 ms / 1,000 ms |
コード長 | 766 bytes |
コンパイル時間 | 1,206 ms |
コンパイル使用メモリ | 143,792 KB |
実行使用メモリ | 7,412 KB |
最終ジャッジ日時 | 2023-08-30 12:50:32 |
合計ジャッジ時間 | 2,318 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 21 ms
7,292 KB |
testcase_01 | AC | 23 ms
7,208 KB |
testcase_02 | AC | 6 ms
7,240 KB |
testcase_03 | AC | 6 ms
7,276 KB |
testcase_04 | AC | 6 ms
7,280 KB |
testcase_05 | AC | 6 ms
7,212 KB |
testcase_06 | AC | 6 ms
7,216 KB |
testcase_07 | AC | 6 ms
7,320 KB |
testcase_08 | AC | 5 ms
7,284 KB |
testcase_09 | AC | 5 ms
7,248 KB |
testcase_10 | AC | 5 ms
7,276 KB |
testcase_11 | AC | 5 ms
7,320 KB |
testcase_12 | AC | 6 ms
7,296 KB |
testcase_13 | AC | 6 ms
7,284 KB |
testcase_14 | AC | 7 ms
7,380 KB |
testcase_15 | AC | 11 ms
7,348 KB |
testcase_16 | AC | 23 ms
7,204 KB |
testcase_17 | AC | 6 ms
7,412 KB |
testcase_18 | AC | 23 ms
7,264 KB |
ソースコード
#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; }