結果
問題 | No.639 An Ordinary Sequence |
ユーザー | fushime2 |
提出日時 | 2018-04-11 19:41:28 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 43 ms / 1,000 ms |
コード長 | 476 bytes |
コンパイル時間 | 4,641 ms |
コンパイル使用メモリ | 457,784 KB |
実行使用メモリ | 4,640 KB |
最終ジャッジ日時 | 2023-09-03 19:21:33 |
合計ジャッジ時間 | 3,915 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
4,640 KB |
testcase_01 | AC | 43 ms
4,568 KB |
testcase_02 | AC | 1 ms
4,356 KB |
testcase_03 | AC | 1 ms
4,352 KB |
testcase_04 | AC | 1 ms
4,352 KB |
testcase_05 | AC | 2 ms
4,352 KB |
testcase_06 | AC | 1 ms
4,352 KB |
testcase_07 | AC | 1 ms
4,356 KB |
testcase_08 | AC | 1 ms
4,356 KB |
testcase_09 | AC | 2 ms
4,352 KB |
testcase_10 | AC | 1 ms
4,356 KB |
testcase_11 | AC | 1 ms
4,356 KB |
testcase_12 | AC | 1 ms
4,356 KB |
testcase_13 | AC | 3 ms
4,360 KB |
testcase_14 | AC | 4 ms
4,388 KB |
testcase_15 | AC | 13 ms
4,480 KB |
testcase_16 | AC | 42 ms
4,636 KB |
testcase_17 | AC | 1 ms
4,356 KB |
testcase_18 | AC | 43 ms
4,572 KB |
ソースコード
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math; static immutable int N = 500000; long[] precalc() { long[] d = new long[N]; d[0] = 1; foreach (i; 1..N) d[i] = d[i/3] + d[i/5]; return d; } void main() { static long[] dp = precalc(); long n; readf("%d\n", &n); long f(long x) { if (x < N) return dp[x.to!int]; return x == 0 ? 1L : f(x/3) + f(x/5); } writeln(f(n)); }