結果
問題 | No.294 SuperFizzBuzz |
ユーザー |
|
提出日時 | 2016-12-29 16:24:32 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 63 ms / 5,000 ms |
コード長 | 1,021 bytes |
コンパイル時間 | 1,986 ms |
コンパイル使用メモリ | 113,536 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 06:10:44 |
合計ジャッジ時間 | 1,643 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 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;}foreach (i; 0..(1<<(keta-1))) {if (i.popcnt % 3 == 2) acm++;if (acm == N) {string ans = "5";foreach (j; 0..keta-1) {ans = ((i & (1 << j)) ? "5" : "3") ~ ans;}ans.writeln;break;}}}