結果
| 問題 |
No.294 SuperFizzBuzz
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-29 15:57:33 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,116 bytes |
| コンパイル時間 | 1,046 ms |
| コンパイル使用メモリ | 127,360 KB |
| 実行使用メモリ | 816,000 KB |
| 最終ジャッジ日時 | 2024-06-12 06:10:34 |
| 合計ジャッジ時間 | 5,039 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 MLE * 1 |
| other | -- * 12 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;
void main() {
auto N = readln.chomp.to!int;
auto nck = new int[][](31, 31);
nck[0][0] = nck[1][0] = nck[1][1] = 1;
foreach (i; 2..31)
foreach (j; 0..i+1)
nck[i][j] = (i == j || j == 0) ? 1 : nck[i-1][j-1] + nck[i-1][j];
int acm, keta;
foreach (i; 3..31) {
int incr = 0;
foreach (j; iota(2, i, 3)) {
incr += nck[i-1][j];
}
if (acm + incr >= N) {
keta = i.to!int;
break;
}
acm += incr;
}
auto perms = new int[][](0);
foreach (i; iota(2, keta, 3)) {
auto p = new int[0];
foreach (j; 0..keta-1) {
p ~= (j < i) ? 5 : 3;
}
p.sort();
perms ~= p.dup;
while (nextPermutation(p)) {
perms ~= p.dup;
}
}
perms.sort();
perms[N-acm-1].map!(d => d.to!string).join("").write;
5.writeln;
}