记录编号 324957 评测结果 AAAAAAAAAA
题目名称 [NOIP 2012]摆花 最终得分 100
用户昵称 Gravatarrewine 是否通过 通过
代码语言 C++ 运行时间 0.011 s
提交时间 2016-10-18 21:31:05 内存使用 0.50 MiB
显示代码纯文本
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <queue>
  7. #define mod 1000007
  8. using namespace std;
  9. int a[200],f[200][200];
  10. bool sg[200][200];
  11. int n,m;
  12. int dfs(int t,int x) {
  13. if(x==m) return 1;
  14. if(x>m) return 0;
  15. if(t>n) return 0;
  16. if(sg[t][x]) return f[t][x];
  17. sg[t][x] = 1;
  18. for (int i = 0; i <= a[t]; i++) {
  19. f[t][x] += dfs(t+1,x+i);
  20. }
  21. f[t][x] %= mod;
  22. return f[t][x];
  23. }
  24. int main()
  25. {
  26. freopen("flower.in","r",stdin);
  27. freopen("flower.out","w",stdout);
  28. ios::sync_with_stdio(false);
  29. cin>>n>>m;
  30. for (int i = 1; i <= n; i++)
  31. cin >> a[i];
  32. cout<<dfs(1,0);
  33. }