fork(1) download
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.io.InputStreamReader;
  5. import java.util.StringTokenizer;
  6.  
  7.  
  8. public class WritingCode {
  9. static int N,M,B,MOD;
  10. static int arr[] = new int[502];
  11. static int dp[][][] = new int[2][502][502];
  12.  
  13. public static void main(String[]args) throws Throwable{
  14. IReader in = new IReader(System.in);
  15. N = in.i();
  16. M = in.i();
  17. B = in.i();
  18. MOD = in.i();
  19. for(int i=1;i<=N;i++) arr[i] = in.i();
  20. dp[0][0][0] = 1;
  21.  
  22.  
  23.  
  24. for(int i=1;i<=N;i++){
  25.  
  26. dp[(i)&1][0][0] =1;
  27. for(int j=1;j<=M;j++){
  28.  
  29. for(int k=0;k<=B;k++){
  30.  
  31. dp[i&1][j][k] += dp[(i-1)&1][j][k]%MOD;
  32. if(k-arr[i]>=0) dp[(i)&1][j][k] += (dp[(i)&1][j-1][k-arr[i]])%MOD;
  33. }
  34. }
  35. }
  36. long sum = 0;
  37. for(int k=0;k<=B;k++) sum+= dp[N&1][M][k]%MOD;
  38. System.out.print(sum);
  39. }
  40. }
  41.  
  42.  
  43. class IReader {
  44. public BufferedReader reader;
  45. public StringTokenizer tokenizer;
  46.  
  47. public IReader(InputStream stream) {
  48. reader = new BufferedReader(new InputStreamReader(stream), 32768);
  49. tokenizer = null;
  50. }
  51.  
  52. public String next() {
  53. while (tokenizer == null || !tokenizer.hasMoreTokens()) {
  54. try {
  55. tokenizer = new StringTokenizer(reader.readLine());
  56. } catch (IOException e) {
  57. throw new RuntimeException(e);
  58. }
  59. }
  60. return tokenizer.nextToken();
  61. }
  62.  
  63. public int i() {
  64. return Integer.parseInt(next());
  65. }
  66.  
  67. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:8: error: class WritingCode is public, should be declared in a file named WritingCode.java
public class WritingCode {
       ^
1 error
stdout
Standard output is empty