結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2015-07-26 00:16:42 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 580 bytes |
コンパイル時間 | 2,315 ms |
コンパイル使用メモリ | 75,616 KB |
実行使用メモリ | 52,408 KB |
最終ジャッジ日時 | 2024-07-08 13:55:41 |
合計ジャッジ時間 | 5,084 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 22 |
ソースコード
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]); } } }