結果

問題 No.1869 Doubling?
ユーザー tentententen
提出日時 2023-02-24 08:20:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,826 bytes
コンパイル時間 2,577 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 49,936 KB
最終ジャッジ日時 2023-10-01 05:28:43
合計ジャッジ時間 7,405 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,524 KB
testcase_01 AC 45 ms
49,376 KB
testcase_02 AC 44 ms
49,288 KB
testcase_03 AC 44 ms
49,348 KB
testcase_04 AC 44 ms
49,864 KB
testcase_05 AC 44 ms
49,448 KB
testcase_06 AC 44 ms
49,392 KB
testcase_07 AC 47 ms
49,316 KB
testcase_08 AC 47 ms
49,296 KB
testcase_09 WA -
testcase_10 AC 45 ms
49,504 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 46 ms
49,360 KB
testcase_16 AC 44 ms
49,404 KB
testcase_17 AC 44 ms
49,440 KB
testcase_18 AC 43 ms
49,484 KB
testcase_19 AC 43 ms
49,372 KB
testcase_20 AC 44 ms
49,448 KB
testcase_21 AC 44 ms
49,704 KB
testcase_22 AC 44 ms
49,324 KB
testcase_23 AC 44 ms
49,316 KB
testcase_24 AC 44 ms
49,348 KB
testcase_25 AC 45 ms
49,628 KB
testcase_26 AC 44 ms
49,248 KB
testcase_27 AC 45 ms
49,300 KB
testcase_28 AC 44 ms
49,472 KB
testcase_29 AC 44 ms
49,364 KB
testcase_30 AC 44 ms
49,432 KB
testcase_31 AC 45 ms
49,380 KB
testcase_32 AC 44 ms
49,320 KB
testcase_33 AC 45 ms
49,304 KB
testcase_34 AC 44 ms
49,380 KB
testcase_35 AC 43 ms
49,396 KB
testcase_36 AC 44 ms
49,360 KB
testcase_37 AC 44 ms
49,236 KB
testcase_38 AC 47 ms
49,388 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 44 ms
49,820 KB
testcase_43 AC 44 ms
49,344 KB
testcase_44 WA -
testcase_45 AC 44 ms
49,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        long total = 0;
        for (int i = 0; i < n; i++) {
            total += m;
            if (m % 2 == 1) {
                m = (m + 1) / 2;
            } else {
                m /= 2;
            }
            if (m == 1) {
                total += n - i - 1;
                break;
            }
        }
        System.out.println(total);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0