From 7183b834e26a4ab1157d71bc2ddedcc0980e403a Mon Sep 17 00:00:00 2001 From: ashutosh Date: Fri, 5 Apr 2024 18:06:40 +0530 Subject: [PATCH] chore: solved hard day 13 task --- medium/day_13/solution.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/medium/day_13/solution.cpp b/medium/day_13/solution.cpp index 8d3ad8d..f319f79 100644 --- a/medium/day_13/solution.cpp +++ b/medium/day_13/solution.cpp @@ -1 +1,32 @@ -//write your code here \ No newline at end of file +//write your code here + + +#include +using namespace std; +long long int a[1000002]={0}; +int main() { + // cout<<5; + long long int n; + cin>>n; + long long int mod=1000000007; + + long long int i,s; + s=0; + a[0]=0; + a[1]=1; + a[2]=2; + s=3; + for(i=3;i<=n;i++) + { + a[i]=(a[i]+a[i-1]+1)%mod; + s=(s+a[i])%mod; + a[i]=(a[i]+a[i-2])%mod; + } + if(n==1) + cout<<1; + else if(n==2) + cout<<3; + else + cout<