-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgiaima.cpp
More file actions
42 lines (40 loc) · 920 Bytes
/
giaima.cpp
File metadata and controls
42 lines (40 loc) · 920 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
36
37
38
39
40
41
42
//
// created by:DungTD
//
#include <bits/stdc++.h>
#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define base int (1e9+7)
#define ll long long
using namespace std;
void solve(){
string s; cin >> s;
if (s[0] == '0') {
cout << 0 << endl; return;
}
int res[100] = {0};
s = " " + s;
res[0] = 1;
res[1] = 1;
int n = s.size();
for (int i=2; i<n; i++) {
if (s[i] == '0' && s[i-1] > '2') {
cout << 0 << endl; return;
}
if (s[i] != '0') res[i] = res[i-1];
int tg = (s[i-1] -'0') * 10 + (s[i] - '0');
if (tg <= 26 && s[i-1] != '0') {
res[i] += res[i-2];
}
}
// for (int i=0; i<n; i++) cout << res[i] << " "; cout << endl;
cout << res[n-1] << endl;
}
int main(){
faster();
int t;
cin >> t;
while (t--)
solve();
return 0;
}