結果
問題 |
No.688 E869120 and Constructing Array 2
|
ユーザー |
![]() |
提出日時 | 2019-12-10 08:43:42 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 994 bytes |
コンパイル時間 | 2,171 ms |
コンパイル使用メモリ | 76,540 KB |
実行使用メモリ | 54,616 KB |
最終ジャッジ日時 | 2024-06-23 20:52:59 |
合計ジャッジ時間 | 4,949 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 1 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int k = sc.nextInt(); HashMap<Integer, Integer> map = new HashMap<>(); for (int i = 2; i <= 30; i++) { map.put(i * (i - 1) / 2, i); } int count0 = 0; int count1 = 0; while (k > 0) { if (map.containsKey(k)) { count1 = map.get(k); if (count1 + count0 <= 30) { break; } } count0++; k /= 2; } StringBuilder sb = new StringBuilder(); sb.append(count0 + count1).append("\n"); for (int i = 0; i < count1; i++) { if (i != 0) { sb.append(" "); } sb.append("1"); } for (int i = 0; i < count0; i++) { sb.append(" ").append("0"); } System.out.println(sb); } }