結果
問題 |
No.2561 みんな大好きmod 998
|
ユーザー |
|
提出日時 | 2023-12-02 14:49:29 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 778 bytes |
コンパイル時間 | 2,434 ms |
コンパイル使用メモリ | 76,900 KB |
実行使用メモリ | 38,040 KB |
最終ジャッジ日時 | 2024-09-26 17:28:47 |
合計ジャッジ時間 | 7,734 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 WA * 4 |
ソースコード
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)%998); br.close(); out.close(); } private static long dfs(int now,long sum,int K,int[] A){ if(K==0) return sum%99824353<=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); } }