結果

問題 No.976 2 の 128 乗と M
ユーザー C_nena_EC_nena_E
提出日時 2020-01-31 21:33:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 580 bytes
コンパイル時間 3,901 ms
コンパイル使用メモリ 74,340 KB
実行使用メモリ 57,648 KB
最終ジャッジ日時 2023-10-17 08:51:25
合計ジャッジ時間 13,100 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,412 KB
testcase_01 AC 132 ms
57,240 KB
testcase_02 AC 133 ms
57,488 KB
testcase_03 AC 136 ms
57,424 KB
testcase_04 AC 131 ms
57,392 KB
testcase_05 AC 132 ms
57,344 KB
testcase_06 AC 135 ms
57,372 KB
testcase_07 AC 137 ms
57,620 KB
testcase_08 AC 133 ms
57,648 KB
testcase_09 AC 132 ms
57,344 KB
testcase_10 AC 134 ms
57,460 KB
testcase_11 AC 134 ms
57,400 KB
testcase_12 AC 132 ms
57,392 KB
testcase_13 AC 134 ms
57,380 KB
testcase_14 AC 133 ms
57,404 KB
testcase_15 AC 133 ms
57,420 KB
testcase_16 AC 135 ms
57,356 KB
testcase_17 AC 132 ms
57,476 KB
testcase_18 AC 134 ms
57,412 KB
testcase_19 AC 132 ms
57,412 KB
testcase_20 AC 135 ms
55,572 KB
testcase_21 AC 132 ms
57,072 KB
testcase_22 AC 136 ms
57,416 KB
testcase_23 AC 136 ms
57,388 KB
testcase_24 AC 133 ms
57,348 KB
testcase_25 AC 133 ms
57,420 KB
testcase_26 AC 135 ms
57,396 KB
testcase_27 AC 133 ms
57,460 KB
testcase_28 AC 132 ms
57,512 KB
testcase_29 AC 131 ms
57,384 KB
testcase_30 AC 135 ms
57,448 KB
testcase_31 AC 134 ms
57,484 KB
testcase_32 AC 134 ms
57,400 KB
testcase_33 AC 135 ms
57,372 KB
testcase_34 AC 134 ms
57,436 KB
testcase_35 AC 136 ms
57,528 KB
testcase_36 AC 136 ms
57,360 KB
testcase_37 AC 134 ms
57,388 KB
testcase_38 AC 135 ms
57,520 KB
testcase_39 AC 133 ms
57,340 KB
testcase_40 AC 135 ms
57,352 KB
testcase_41 AC 135 ms
57,484 KB
testcase_42 AC 135 ms
57,384 KB
testcase_43 AC 133 ms
57,376 KB
testcase_44 AC 133 ms
57,408 KB
testcase_45 AC 136 ms
57,332 KB
testcase_46 AC 133 ms
57,344 KB
testcase_47 AC 135 ms
57,344 KB
testcase_48 AC 135 ms
57,384 KB
testcase_49 AC 135 ms
57,356 KB
testcase_50 AC 137 ms
57,640 KB
testcase_51 AC 134 ms
57,628 KB
testcase_52 AC 133 ms
57,416 KB
testcase_53 AC 134 ms
57,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long m = sc.nextLong();
        long max_2 = 1;
        int cnt = 0;
        for(int i = 1; i <= 128; i++){
            max_2 *= 2;
            if(max_2 >= m){
                cnt = i;
                break;
            }
        }
        long ans = max_2 % m;
        for(int i = cnt+1; i <= 128; i++){
            ans = (ans*2)%m;
        }
        System.out.println(ans);
    }
}

0