結果

問題 No.294 SuperFizzBuzz
ユーザー nebukuro09nebukuro09
提出日時 2016-12-29 15:57:33
言語 D
(dmd 2.106.1)
結果
MLE  
実行時間 -
コード長 1,116 bytes
コンパイル時間 857 ms
コンパイル使用メモリ 117,760 KB
実行使用メモリ 817,884 KB
最終ジャッジ日時 2023-09-03 00:18:30
合計ジャッジ時間 6,384 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 MLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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;

}
0