結果

問題 No.1869 Doubling?
ユーザー tentententen
提出日時 2022-03-18 11:55:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,214 bytes
コンパイル時間 1,749 ms
コンパイル使用メモリ 77,740 KB
実行使用メモリ 50,384 KB
最終ジャッジ日時 2024-04-10 12:49:15
合計ジャッジ時間 4,969 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
37,224 KB
testcase_01 AC 44 ms
37,352 KB
testcase_02 AC 44 ms
37,116 KB
testcase_03 AC 44 ms
37,268 KB
testcase_04 AC 45 ms
37,220 KB
testcase_05 AC 44 ms
37,212 KB
testcase_06 AC 44 ms
37,132 KB
testcase_07 AC 44 ms
37,048 KB
testcase_08 AC 45 ms
37,120 KB
testcase_09 AC 45 ms
37,352 KB
testcase_10 AC 45 ms
36,840 KB
testcase_11 AC 46 ms
37,296 KB
testcase_12 AC 44 ms
37,280 KB
testcase_13 AC 46 ms
36,704 KB
testcase_14 AC 46 ms
37,280 KB
testcase_15 AC 44 ms
37,024 KB
testcase_16 AC 44 ms
36,860 KB
testcase_17 AC 45 ms
36,732 KB
testcase_18 AC 45 ms
36,720 KB
testcase_19 AC 43 ms
36,944 KB
testcase_20 AC 45 ms
37,220 KB
testcase_21 AC 46 ms
37,352 KB
testcase_22 AC 45 ms
37,132 KB
testcase_23 AC 46 ms
36,816 KB
testcase_24 AC 45 ms
37,224 KB
testcase_25 AC 44 ms
37,056 KB
testcase_26 AC 44 ms
37,148 KB
testcase_27 AC 44 ms
36,860 KB
testcase_28 AC 47 ms
37,272 KB
testcase_29 AC 47 ms
37,308 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 44 ms
37,232 KB
testcase_34 AC 44 ms
36,980 KB
testcase_35 AC 44 ms
37,392 KB
testcase_36 AC 44 ms
37,320 KB
testcase_37 AC 46 ms
37,252 KB
testcase_38 AC 46 ms
37,320 KB
testcase_39 AC 45 ms
37,152 KB
testcase_40 AC 44 ms
36,724 KB
testcase_41 AC 45 ms
36,964 KB
testcase_42 WA -
testcase_43 AC 47 ms
37,092 KB
testcase_44 AC 44 ms
37,004 KB
testcase_45 AC 45 ms
37,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        if (n <= 30 && (1 << (n - 1)) <= m) {
            System.out.println((1 << n) - 1);
            return;
        }
        int total = 0;
        while (m > 1) {
            total += m;
            m = (m + 1) / 2;
            n--;
        }
        total += n;
        System.out.println(total);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0