-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1b3083
commit 9438e5e
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <bits/stdc++.h> | ||
#include<cstring> | ||
using namespace std; | ||
typedef long long ll; | ||
|
||
long long mod= pow(10,9)+7; | ||
long long ans(string input,int a) | ||
{ | ||
long long dp[a+1]={0}; | ||
dp[0]=1; | ||
dp[1]=1; | ||
for(int i=2;i<=a;i++) | ||
{ | ||
if(input[i-1]!='0') | ||
dp[i]=dp[i-1]; | ||
int num=(input[i-2]-'0')*10+(input[i-1]-'0'); | ||
if(num>=10&&num<=26) | ||
dp[i]=(dp[i-2]%mod+dp[i]%mod)%mod; | ||
|
||
} | ||
return dp[a]; | ||
} | ||
|
||
int main() | ||
{ | ||
|
||
for(;;){ | ||
string input; | ||
cin>>input; | ||
if(input[0]=='0') | ||
return 0; | ||
int a=input.size(); | ||
cout<<ans(input,a)<<endl; | ||
|
||
} | ||
return 0; | ||
} | ||
|