結果
問題 | No.3 ビットすごろく |
ユーザー | kuramu |
提出日時 | 2016-01-20 12:38:42 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,134 bytes |
コンパイル時間 | 2,244 ms |
コンパイル使用メモリ | 78,736 KB |
実行使用メモリ | 57,716 KB |
最終ジャッジ日時 | 2023-10-21 13:29:53 |
合計ジャッジ時間 | 6,620 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 57 ms
53,596 KB |
testcase_01 | AC | 56 ms
53,600 KB |
testcase_02 | AC | 56 ms
53,596 KB |
testcase_03 | AC | 86 ms
54,196 KB |
testcase_04 | AC | 66 ms
53,608 KB |
testcase_05 | AC | 102 ms
57,328 KB |
testcase_06 | AC | 76 ms
54,428 KB |
testcase_07 | AC | 81 ms
54,176 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 96 ms
57,208 KB |
testcase_13 | AC | 83 ms
53,640 KB |
testcase_14 | AC | 103 ms
57,316 KB |
testcase_15 | AC | 108 ms
57,500 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 81 ms
54,152 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 58 ms
53,576 KB |
testcase_22 | AC | 94 ms
57,080 KB |
testcase_23 | AC | 107 ms
56,776 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 56 ms
53,584 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 58 ms
53,612 KB |
testcase_32 | WA | - |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; public class Main { public static void main(String[] args) { BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in)); try { int N = Integer.parseInt(stdReader.readLine()); int[] c = new int[N+1]; for(int i=1;i<N+1;i++){ int count = 0; String bin = Integer.toBinaryString(i); for(int j=0;j<bin.length();j++){ if((""+bin.charAt(j)).equals("1")) count++; } c[i] = count; } int result = 1; int here = 1; HashMap<Integer , String> hMap = new HashMap<>(); while(here<N){ if(hMap.containsKey(here)){ result = -1; break; }else{ hMap.put(here, ""); } if(here + c[here]<=N) here += c[here]; else if(here + c[here]>N) here -= c[here]; result++; } System.out.println(result); } catch (IOException e) { e.printStackTrace(); } } }