結果

問題 No.2561 みんな大好きmod 998
ユーザー viral8viral8
提出日時 2023-12-02 14:50:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 99 ms / 4,000 ms
コード長 781 bytes
コンパイル時間 1,870 ms
コンパイル使用メモリ 77,364 KB
実行使用メモリ 55,136 KB
最終ジャッジ日時 2023-12-02 14:50:46
合計ジャッジ時間 6,126 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
54,120 KB
testcase_01 AC 63 ms
55,024 KB
testcase_02 AC 47 ms
54,124 KB
testcase_03 AC 95 ms
55,028 KB
testcase_04 AC 93 ms
55,024 KB
testcase_05 AC 98 ms
55,008 KB
testcase_06 AC 99 ms
55,016 KB
testcase_07 AC 49 ms
54,116 KB
testcase_08 AC 48 ms
54,116 KB
testcase_09 AC 49 ms
52,048 KB
testcase_10 AC 47 ms
54,128 KB
testcase_11 AC 69 ms
55,020 KB
testcase_12 AC 48 ms
54,120 KB
testcase_13 AC 47 ms
54,128 KB
testcase_14 AC 47 ms
54,120 KB
testcase_15 AC 98 ms
55,028 KB
testcase_16 AC 47 ms
54,120 KB
testcase_17 AC 47 ms
54,132 KB
testcase_18 AC 48 ms
54,128 KB
testcase_19 AC 89 ms
55,136 KB
testcase_20 AC 48 ms
54,120 KB
testcase_21 AC 48 ms
54,128 KB
testcase_22 AC 49 ms
54,104 KB
testcase_23 AC 48 ms
54,128 KB
testcase_24 AC 48 ms
54,128 KB
testcase_25 AC 51 ms
54,128 KB
testcase_26 AC 71 ms
55,044 KB
testcase_27 AC 96 ms
55,004 KB
testcase_28 AC 72 ms
55,016 KB
testcase_29 AC 66 ms
55,024 KB
testcase_30 AC 69 ms
55,008 KB
testcase_31 AC 81 ms
55,012 KB
testcase_32 AC 67 ms
55,008 KB
testcase_33 AC 65 ms
55,020 KB
testcase_34 AC 96 ms
55,016 KB
testcase_35 AC 64 ms
55,024 KB
testcase_36 AC 64 ms
55,028 KB
testcase_37 AC 60 ms
55,008 KB
testcase_38 AC 69 ms
55,024 KB
testcase_39 AC 70 ms
55,016 KB
testcase_40 AC 70 ms
55,024 KB
testcase_41 AC 69 ms
55,016 KB
testcase_42 AC 70 ms
55,028 KB
testcase_43 AC 62 ms
55,016 KB
testcase_44 AC 66 ms
55,028 KB
testcase_45 AC 86 ms
55,016 KB
testcase_46 AC 64 ms
55,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
class Main{
	private static final BufferedReader br =
		new BufferedReader(new InputStreamReader(System.in));
	private static final PrintWriter out =
		new PrintWriter(System.out);
	public static void main(String[] args)throws IOException{

		String[] str = br.readLine().split(" ");
		int N = Integer.parseInt(str[0]);
		int K = Integer.parseInt(str[1]);
		str = br.readLine().split(" ");
		int[] A = new int[N];
		for(int i=0;i<N;i++)
			A[i] = Integer.parseInt(str[i]);
		out.println(dfs(0,0,K,A));

		br.close();
		out.close();
	}
	private static long dfs(int now,long sum,int K,int[] A){
		if(K==0)
			return sum%998244353<=sum%998?1:0;
		if(now==A.length)
			return 0;
		return (dfs(now+1,sum,K,A)+dfs(now+1,sum+A[now],K-1,A))%998;
	}
}
0