Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: solved hard day 13 task #104

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion medium/day_13/solution.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
//write your code here
//write your code here


#include <iostream>
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<<s;
return 0;
}
Loading