結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2015-07-26 00:21:29 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 580 bytes |
コンパイル時間 | 1,761 ms |
コンパイル使用メモリ | 74,936 KB |
実行使用メモリ | 52,320 KB |
最終ジャッジ日時 | 2024-07-08 13:55:54 |
合計ジャッジ時間 | 4,400 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 18 |
ソースコード
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]=1; 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]); } } }