結果
| 問題 | No.2561 みんな大好きmod 998 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-12-02 14:50:40 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 121 ms / 4,000 ms | 
| コード長 | 781 bytes | 
| コンパイル時間 | 2,553 ms | 
| コンパイル使用メモリ | 76,620 KB | 
| 実行使用メモリ | 37,912 KB | 
| 最終ジャッジ日時 | 2024-09-26 17:31:13 | 
| 合計ジャッジ時間 | 7,687 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 44 | 
ソースコード
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;
	}
}
            
            
            
        