結果
問題 | No.639 An Ordinary Sequence |
ユーザー |
![]() |
提出日時 | 2018-04-11 20:16:28 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 30 ms / 1,000 ms |
コード長 | 476 bytes |
コンパイル時間 | 3,474 ms |
コンパイル使用メモリ | 640,372 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 00:23:00 |
合計ジャッジ時間 | 3,833 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 = 800000; 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)); }