Advertisement
TheAnshul

spliting problem

Aug 26th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. /***** TheAnshul *****/
  2.  
  3. #include<bits/stdc++.h>
  4. #define ll long long
  5. #define pb push_back
  6. #define ppb pop_back
  7. #define endl '\n'
  8. #define mii map<ll int,ll int>
  9. #define msi map<string,ll int>
  10. #define mis map<ll int, string>
  11. #define rep(i,a,b) for(ll int i=a;i<b;i++)
  12. #define mpi map<pair<ll int,ll int>,ll int>
  13. #define pii pair<ll int,ll int>
  14. #define vi vector<ll int>
  15. #define vii vector<pair<ll int, ll int>>
  16. #define vs vector<string>
  17. #define all(a) (a).begin(),(a).end()
  18. #define F first
  19. #define S second
  20. #define sz(x) (ll int)x.size()
  21. #define hell 1000000007
  22. #define lbnd lower_bound
  23. #define ubnd upper_bound
  24. #define bs binary_search
  25. #define mp make_pair
  26. #define what_is(x) cerr << #x << " is " << x << endl;
  27. using namespace std;
  28. #define N 23153
  29. int main()
  30. {
  31. ios_base::sync_with_stdio(false);
  32. cin.tie(0);
  33. cout.tie(0);
  34. int TESTS=1;
  35. // cin>>TESTS;
  36. while(TESTS--)
  37. {
  38. ll n;
  39. cin>>n;
  40. ll vl;
  41. vector<ll>mp(n+1,0);
  42. rep(i,1,n+1)
  43. {
  44. vl=(i*(3*i+1))/2;
  45. if(i&1)
  46. {
  47. if(vl>=0 && vl<=n)
  48. mp[vl]=1;
  49. }
  50. else
  51. {
  52. if(vl>=0 && vl<=n)
  53. mp[vl]=-1;
  54. }
  55. vl=(i*(3*i-1))/2;
  56. if(i&1)
  57. {
  58. if(vl>=0 && vl<=n)
  59. mp[vl]=1;
  60. }
  61. else
  62. {
  63. if(vl>=0 && vl<=n)
  64. mp[vl]=-1;
  65. }
  66. }
  67. ll dp[n+1];
  68. dp[0]=1;
  69. cout<<mp[1]<<endl;
  70. rep(i,1,n+1)
  71. {
  72. ll sum=0,vl;
  73. rep(j,1,i+1)
  74. {
  75. sum+=(mp[j]*dp[i-j]+2*hell)%hell;
  76. sum%=hell;
  77. }
  78. dp[i]=sum;
  79. }
  80. cout<<dp[n];
  81. }
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement