結果
問題 | No.639 An Ordinary Sequence |
ユーザー |
![]() |
提出日時 | 2018-04-11 19:41:28 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 39 ms / 1,000 ms |
コード長 | 476 bytes |
コンパイル時間 | 2,816 ms |
コンパイル使用メモリ | 450,432 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-13 00:22:18 |
合計ジャッジ時間 | 4,089 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 |
ソースコード
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)); }