結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2015-07-26 00:14:53 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 580 bytes |
コンパイル時間 | 2,198 ms |
コンパイル使用メモリ | 74,612 KB |
実行使用メモリ | 37,372 KB |
最終ジャッジ日時 | 2024-07-08 13:55:36 |
合計ジャッジ時間 | 5,197 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 23 |
ソースコード
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; dp[1]=0; Arrays.fill(dp,-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]); } } }