We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f049c4c commit 9b078baCopy full SHA for 9b078ba
2021/Div 2/742/Programs/Carrying Conundrum.cpp
@@ -0,0 +1,39 @@
1
+#include <iostream>
2
+
3
+using namespace std;
4
5
+void solve()
6
+{
7
+ string n;
8
+ cin >> n;
9
10
+ long long odd_places = 0, even_places = 0;
11
+ for(int i = 0; i < n.size(); i++)
12
+ {
13
+ int digit = n[i] - '0';
14
15
+ switch(i%2)
16
17
+ case 1 : odd_places = odd_places*10 + digit;
18
+ break;
19
20
+ case 0 : even_places = even_places*10 + digit;
21
22
+ }
23
24
25
+ long long total_ways = (odd_places + 1)*(even_places + 1) - 2;
26
27
+ cout << total_ways << "\n";
28
+}
29
30
+int main()
31
32
+ int no_of_test_cases;
33
+ cin >> no_of_test_cases;
34
35
+ while(no_of_test_cases--)
36
+ solve();
37
38
+ return 0;
39
0 commit comments