結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
shiyo1023
|
| 提出日時 | 2019-09-02 15:29:17 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 776 bytes |
| 記録 | |
| コンパイル時間 | 2,266 ms |
| コンパイル使用メモリ | 82,072 KB |
| 実行使用メモリ | 1,018,048 KB |
| 最終ジャッジ日時 | 2026-05-26 05:39:14 |
| 合計ジャッジ時間 | 11,704 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 TLE * 1 MLE * 2 -- * 28 |
ソースコード
import java.util.Scanner;
public class Main {
private static int N;
private static int min = -1;
private static boolean flag[] = new boolean[10000];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
N = sc.nextInt();
dfs(1, 1);
System.out.println(min);
}
private static void dfs(int a, int c){
if(a<1 || a>N){
return;
}
if(flag[a-1] == true){
return;
}
if(min != -1 && c>=min){
//flag[a-1] = true;
return;
}
if(a==N){
min = c;
}
int b = Integer.bitCount(a);
dfs(a+b, c+1);
dfs(a-b, c+1);
}
}
shiyo1023