結果
問題 |
No.688 E869120 and Constructing Array 2
|
ユーザー |
|
提出日時 | 2018-09-30 18:16:52 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 137 ms / 1,000 ms |
コード長 | 580 bytes |
コンパイル時間 | 2,056 ms |
コンパイル使用メモリ | 77,728 KB |
実行使用メモリ | 54,208 KB |
最終ジャッジ日時 | 2024-10-12 09:15:36 |
合計ジャッジ時間 | 4,635 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int K = sc.nextInt(), i, j = 0; sc.close(); for (i = 1; i <= 30; ++i) { for (j = 0; j <= 30 - i; ++j) { if ((i - 1) * i / 2 * (int)Math.pow(2, j) == K) break; } if (j != 31 - i) break; } System.out.println(i + j); for (int k = 0; k < i; ++k) System.out.print("1 "); for (int l = 0; l < j; ++l) System.out.print("0 "); } }