結果
| 問題 |
No.639 An Ordinary Sequence
|
| コンテスト | |
| ユーザー |
fushime2
|
| 提出日時 | 2018-04-11 19:40:58 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 527 bytes |
| コンパイル時間 | 2,907 ms |
| コンパイル使用メモリ | 451,764 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-13 00:19:55 |
| 合計ジャッジ時間 | 3,796 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 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();
writeln(dp[33]);
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));
auto _ = readln(); // dbg
}
fushime2