Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n=int(input())
- mp=[0]*(n+1)
- for i in range(1,n+1):
- vl=int((i*(3*i+1))//2)
- if i%2==1:
- if vl>=0 and vl<=n:
- mp[vl]=1
- else:
- if vl>=0 and vl<=n:
- mp[vl]=-1
- vl=int((i*(3*i-1))//2)
- if i%2==1:
- if vl>=0 and vl<=n:
- mp[vl]=1
- else:
- if vl>=0 and vl<=n:
- mp[vl]=-1
- dp=[0]*(n+1)
- dp[0]=1
- # print(mp[1])
- for i in range(1,n+1):
- sum=0
- for j in range(1,i+1):
- sum+=(mp[j]*dp[i-j])
- dp[i]=sum
- print(dp[n])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement