From 541db663181f9be3ab06f9dfcb310119d221263a Mon Sep 17 00:00:00 2001 From: ashish007kumar Date: Thu, 1 Oct 2020 00:14:49 +0530 Subject: [PATCH] cpp --- DP/Consecutive 1's not allowed.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 DP/Consecutive 1's not allowed.cpp diff --git a/DP/Consecutive 1's not allowed.cpp b/DP/Consecutive 1's not allowed.cpp new file mode 100644 index 0000000..b11aee5 --- /dev/null +++ b/DP/Consecutive 1's not allowed.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; +int mod=1000000007; +int main(){ + //code + long long int dp[101]; + dp[0]=1; + dp[1]=2; + for(int i=2;i<101;i++){ + dp[i]=( dp[i-1]%mod + dp[i-2]%mod )% mod; + } + int t; + cin>>t; + while(t--){ + int n; + cin>>n; + cout<