-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2011.cpp
More file actions
35 lines (35 loc) · 821 Bytes
/
2011.cpp
File metadata and controls
35 lines (35 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <string>
#include <stdlib.h>
#define MAX 5001
#define MOD 1000000
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
string num;
cin >> num;
long long dp[MAX]= {1,1,};
int size = num.size();
int n;
for(int i = 2; i<=size; i++){
char ch[2] = {num[i-2],num[i-1]};
n = atoi(ch);
if(n == 30 || n == 40 || n == 50 || n == 60 || n == 70 || n == 80 || n == 90){
dp[size] = 0;
}
else if(n == 10 || n == 20){
dp[i] = dp[i-2] % MOD;
}
else if(n<27 && n >10 && n != 20){
dp[i] = (dp[i-1] +dp[i-2])%MOD;
}else{
dp[i] = dp[i-1]%MOD;
}
}
if(num[0] == '0'){
dp[size] = 0;
}
cout << dp[size];
return 0;
}