結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2017-03-20 15:00:38 |
言語 | Java (openjdk 23) |
結果 |
MLE
|
実行時間 | - |
コード長 | 847 bytes |
コンパイル時間 | 3,486 ms |
コンパイル使用メモリ | 77,444 KB |
実行使用メモリ | 832,632 KB |
最終ジャッジ日時 | 2024-07-05 03:19:09 |
合計ジャッジ時間 | 6,135 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 MLE * 1 -- * 29 |
ソースコード
import java.util.Scanner; public class Bitsugoroku { static int N; static boolean tof = false; public static void main(String[] args) { Scanner s = new Scanner(System.in); int p = 1,count = 1; N = s.nextInt(); s.close(); if(N == 1){ count = 1; }else{ int h = Sugo(p,count); if(h == 0){ count = 0; }else{ count += h; } } if(count == 0){ System.out.println(-1); }else{ System.out.println(count); } } static int Sugo(int p,int count){ int d = Integer.bitCount(p); if(p + d > N){ tof = true; int k = Sugo(p - d,count); if(k == 0){ count = 0; }else{ count += k; } }else if(p + d == N){ count = 1; }else if(p - d <= 3 && tof){ count = 0; }else{ int h = Sugo(p+d,count); if(h==0){ count = 0; }else{ count += h; } } return count; } }