Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***** TheAnshul *****/
- #include<bits/stdc++.h>
- #define ll long long
- #define pb push_back
- #define ppb pop_back
- #define endl '\n'
- #define mii map<ll int,ll int>
- #define msi map<string,ll int>
- #define mis map<ll int, string>
- #define rep(i,a,b) for(ll int i=a;i<b;i++)
- #define mpi map<pair<ll int,ll int>,ll int>
- #define pii pair<ll int,ll int>
- #define vi vector<ll int>
- #define vii vector<pair<ll int, ll int>>
- #define vs vector<string>
- #define all(a) (a).begin(),(a).end()
- #define F first
- #define S second
- #define sz(x) (ll int)x.size()
- #define hell 1000000007
- #define lbnd lower_bound
- #define ubnd upper_bound
- #define bs binary_search
- #define mp make_pair
- #define what_is(x) cerr << #x << " is " << x << endl;
- using namespace std;
- #define N 23153
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int TESTS=1;
- // cin>>TESTS;
- while(TESTS--)
- {
- ll n;
- cin>>n;
- ll vl;
- vector<ll>mp(n+1,0);
- rep(i,1,n+1)
- {
- vl=(i*(3*i+1))/2;
- if(i&1)
- {
- if(vl>=0 && vl<=n)
- mp[vl]=1;
- }
- else
- {
- if(vl>=0 && vl<=n)
- mp[vl]=-1;
- }
- vl=(i*(3*i-1))/2;
- if(i&1)
- {
- if(vl>=0 && vl<=n)
- mp[vl]=1;
- }
- else
- {
- if(vl>=0 && vl<=n)
- mp[vl]=-1;
- }
- }
- ll dp[n+1];
- dp[0]=1;
- cout<<mp[1]<<endl;
- rep(i,1,n+1)
- {
- ll sum=0,vl;
- rep(j,1,i+1)
- {
- sum+=(mp[j]*dp[i-j]+2*hell)%hell;
- sum%=hell;
- }
- dp[i]=sum;
- }
- cout<<dp[n];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement