結果

問題 No.3 ビットすごろく
ユーザー holegumaholeguma
提出日時 2015-07-26 00:16:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 580 bytes
コンパイル時間 2,466 ms
コンパイル使用メモリ 72,212 KB
実行使用メモリ 52,640 KB
最終ジャッジ日時 2023-09-22 23:15:17
合計ジャッジ時間 4,836 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 48 ms
49,448 KB
testcase_03 AC 48 ms
47,692 KB
testcase_04 WA -
testcase_05 AC 49 ms
49,196 KB
testcase_06 AC 48 ms
49,252 KB
testcase_07 WA -
testcase_08 AC 48 ms
49,308 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 49 ms
49,512 KB
testcase_13 AC 49 ms
49,328 KB
testcase_14 AC 50 ms
49,256 KB
testcase_15 AC 49 ms
49,316 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 49 ms
49,436 KB
testcase_23 AC 48 ms
49,268 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Arrays;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
int[] dp=new int[10001];
int now=1;
int count;
Arrays.fill(dp,-1);
dp[1]=0;
while(true){
count=0;
String val2=Integer.toBinaryString(now);
for(int i=0;i<val2.length();i++){
if(val2.charAt(i)=='1'){
count++;
}
}
if(now+count>10000){
break;
}
dp[now+count]=dp[now]+1;
now+=count;
}
while((line=br.readLine())!=null){
int n=Integer.parseInt(line);
System.out.println(dp[n]);
}
}
}
0