結果
問題 | No.294 SuperFizzBuzz |
ユーザー | 37zigen |
提出日時 | 2017-02-03 10:15:24 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 150 ms / 5,000 ms |
コード長 | 1,242 bytes |
コンパイル時間 | 2,050 ms |
コンパイル使用メモリ | 74,588 KB |
実行使用メモリ | 56,152 KB |
最終ジャッジ日時 | 2023-08-25 18:17:26 |
合計ジャッジ時間 | 5,158 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 125 ms
55,504 KB |
testcase_01 | AC | 125 ms
55,824 KB |
testcase_02 | AC | 150 ms
55,784 KB |
testcase_03 | AC | 118 ms
55,760 KB |
testcase_04 | AC | 123 ms
56,036 KB |
testcase_05 | AC | 122 ms
55,660 KB |
testcase_06 | AC | 123 ms
55,808 KB |
testcase_07 | AC | 126 ms
55,984 KB |
testcase_08 | AC | 132 ms
56,064 KB |
testcase_09 | AC | 140 ms
56,152 KB |
testcase_10 | AC | 121 ms
55,640 KB |
testcase_11 | AC | 143 ms
55,796 KB |
testcase_12 | AC | 143 ms
55,304 KB |
testcase_13 | AC | 150 ms
56,140 KB |
testcase_14 | AC | 144 ms
56,064 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long[][] nCk = new long[26][26]; nCk[0][0] = 1; for (int i = 1; i <= 25; ++i) { for (int j = 0; j <= i; ++j) { nCk[i][j] = (j > 0 ? nCk[i - 1][j - 1] : 0) + (i - 1 >= j ? nCk[i - 1][j] : 0); } } long[] count = new long[26];// count[i]:i桁の時の組み合わせの数 for (int i = 1; i < count.length; ++i) { count[i] = count[i - 1]; for (int j = 3; j <= i; j += 3) { count[i] += nCk[i - 1][j - 1]; } } int N = sc.nextInt(); int digit = 0; while (count[digit] < N) ++digit; long cnt = N - count[digit - 1]; for (int i = 1; i < (1 << digit); i += 2) { int c5 = Integer.bitCount(i); if (c5 % 3 == 0) { --cnt; } if (cnt == 0) { for (int j = digit - 1; j >= 0; --j) { if (((1 << j) & i) > 0) { System.out.print(5); } else { System.out.print(3); } } System.out.println(); return; } } tr(count[digit]); tr(count); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }