結果
問題 |
No.688 E869120 and Constructing Array 2
|
ユーザー |
|
提出日時 | 2018-05-18 22:35:48 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 986 bytes |
コンパイル時間 | 4,299 ms |
コンパイル使用メモリ | 78,356 KB |
実行使用メモリ | 41,736 KB |
最終ジャッジ日時 | 2024-07-07 13:26:10 |
合計ジャッジ時間 | 6,638 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 1 |
ソースコード
import java.io.*; import java.util.*; public class Main_yukicoder688 { private static Scanner sc; private static Printer pr; private static void solve() { int k = sc.nextInt(); for (int i = 0; true; i++) { int tmp = (int)Math.sqrt(k * 2); if (tmp * (tmp + 1) == k * 2) { int cnt = tmp + 1 + i; pr.println(cnt); for (int j = 0; j < cnt; j++) { if (j > 0) { pr.print(' '); } if (j < tmp + 1) { pr.print(1); } else { pr.print(0); } } pr.println(); return; } k /= 2; } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes())); pr = new Printer(System.out); solve(); // pr.close(); pr.flush(); // sc.close(); } static String INPUT = null; private static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }