fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #define llong long long
  4.  
  5. using namespace std;
  6.  
  7. int n, k;
  8. llong dp[10006], tmp[10006];
  9. const int mod = 1e9+7;
  10.  
  11. int main() {
  12. cin >> n >> k;
  13. for(int i=1; i<=n; ++i) {
  14. tmp[0] = 1;
  15. for(int j=1; j<=k; ++j) {
  16. llong val = (dp[j] - ((j - i >= 0) ? dp[j-i] : 0) + mod) % mod;
  17. tmp[j] = (tmp[j-1] + val) % mod;
  18. }
  19. for(int j=0; j<=k; ++j) dp[j] = tmp[j];
  20. }
  21. cout << (dp[k] - ((k > 0) ? dp[k-1] : 0) + mod) % mod;
  22. return 0;
  23. }
Success #stdin #stdout 0s 4516KB
stdin
Standard input is empty
stdout
Standard output is empty