fork(2) download
  1. #include <bits/stdc++.h>
  2. const int mod = 1e9 + 7;
  3. int n, c, dp[2][10005];
  4. int main(){
  5. scanf("%d%d", &n, &c); dp[0][0] = 1;
  6. for (int i = 1; i <= n; i++)
  7. for (int j = 0; j <= c; j++)
  8. dp[i%2][j]=j?((dp[(i+1)%2][j]-(j>=i?dp[(i+1)%2][j-i]:0)+mod)%mod+dp[i%2][j-1])%mod:1;
  9. printf("%d", dp[n%2][c] - dp[n%2][c + 1]);
  10. }
Success #stdin #stdout 0s 4532KB
stdin
Standard input is empty
stdout
1