結果

問題 No.2060 AND Sequence
ユーザー ks2mks2m
提出日時 2022-08-26 22:01:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 3,876 ms
コンパイル使用メモリ 75,644 KB
実行使用メモリ 37,388 KB
最終ジャッジ日時 2024-04-22 00:06:36
合計ジャッジ時間 8,324 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
36,820 KB
testcase_01 AC 46 ms
37,196 KB
testcase_02 AC 47 ms
37,208 KB
testcase_03 AC 48 ms
37,152 KB
testcase_04 AC 47 ms
36,808 KB
testcase_05 AC 46 ms
37,216 KB
testcase_06 AC 47 ms
36,652 KB
testcase_07 AC 48 ms
37,000 KB
testcase_08 AC 48 ms
37,348 KB
testcase_09 AC 48 ms
36,960 KB
testcase_10 AC 46 ms
37,188 KB
testcase_11 AC 46 ms
36,896 KB
testcase_12 AC 46 ms
36,892 KB
testcase_13 AC 45 ms
37,120 KB
testcase_14 AC 47 ms
36,944 KB
testcase_15 AC 47 ms
36,988 KB
testcase_16 AC 46 ms
36,944 KB
testcase_17 AC 45 ms
36,944 KB
testcase_18 AC 45 ms
37,104 KB
testcase_19 AC 45 ms
37,128 KB
testcase_20 AC 47 ms
37,080 KB
testcase_21 AC 46 ms
36,900 KB
testcase_22 AC 50 ms
37,388 KB
testcase_23 AC 47 ms
37,240 KB
testcase_24 AC 46 ms
36,724 KB
testcase_25 AC 46 ms
36,704 KB
testcase_26 AC 45 ms
37,236 KB
testcase_27 AC 46 ms
36,920 KB
testcase_28 AC 49 ms
37,220 KB
testcase_29 AC 49 ms
36,844 KB
testcase_30 AC 46 ms
37,156 KB
testcase_31 AC 46 ms
37,176 KB
testcase_32 AC 45 ms
37,136 KB
testcase_33 AC 46 ms
36,920 KB
testcase_34 AC 45 ms
36,724 KB
testcase_35 AC 45 ms
36,696 KB
testcase_36 AC 46 ms
36,984 KB
testcase_37 AC 47 ms
37,128 KB
testcase_38 AC 45 ms
37,012 KB
testcase_39 AC 46 ms
37,184 KB
testcase_40 AC 46 ms
36,920 KB
testcase_41 AC 46 ms
36,828 KB
testcase_42 AC 46 ms
36,900 KB
testcase_43 AC 47 ms
36,960 KB
testcase_44 AC 47 ms
37,104 KB
testcase_45 AC 46 ms
36,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		br.close();

		int mod = 998244353;
		int x = 31;
		long[] dp0 = new long[x];
		long[] dp1 = new long[x];
		dp0[x - 1] = 1;
		for (int i = x - 2; i >= 0; i--) {
			if ((m >> i & 1) == 1) {
				dp0[i] += dp0[i + 1] * n;
				dp1[i] += dp0[i + 1];
			} else {
				dp0[i] += dp0[i + 1];
			}
			dp1[i] += dp1[i + 1] * (n + 1);
			dp0[i] %= mod;
			dp1[i] %= mod;
		}
		long ans = dp0[0] + dp1[0];
		ans %= mod;
		System.out.println(ans);
	}
}
0