結果
問題 | No.688 E869120 and Constructing Array 2 |
ユーザー | YamaKasa |
提出日時 | 2018-05-18 23:20:53 |
言語 | Java21 (openjdk 21) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 894 bytes |
コンパイル時間 | 2,117 ms |
コンパイル使用メモリ | 74,368 KB |
実行使用メモリ | 57,856 KB |
最終ジャッジ日時 | 2023-09-21 20:06:24 |
合計ジャッジ時間 | 5,367 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 128 ms
55,568 KB |
testcase_01 | AC | 127 ms
56,168 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 130 ms
55,536 KB |
testcase_05 | WA | - |
testcase_06 | AC | 128 ms
55,800 KB |
testcase_07 | WA | - |
testcase_08 | AC | 124 ms
55,644 KB |
testcase_09 | WA | - |
testcase_10 | AC | 123 ms
55,772 KB |
testcase_11 | AC | 122 ms
55,844 KB |
testcase_12 | AC | 126 ms
55,776 KB |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long K = scan.nextInt(); scan.close(); int index1 = 2; int index2 = 0; int flag = 0; for(int i = 2; i < 30; i++) { long x = i * (i - 1); index1 = i; for(int j = 0; j < 30 - i; j++) { long y; y = (long)Math.pow(2, j); if(x * y == 2 * K) { index2 = j; flag = 1; break; } } if(flag == 1) { break; } } System.out.println(index1 + index2); for(int i = 0; i < index1; i++) { if(i == index1 - 1) { System.out.print(1); }else { System.out.print(1 + " "); } } for(int i = 1; i < index2; i++) { if(i == 1) { System.out.print(" " + 0 + " "); } if(i == index2 - 1) { System.out.print(0); }else { System.out.print(0 + " "); } } System.out.println(); } }