-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path090.cpp
101 lines (92 loc) · 1.54 KB
/
090.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <iostream>
#include <cmath>
//#include <climits>
#include <string>
//#include <algorithm>
using namespace std;
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
string s, s1 = "", s2 = "";
getline(cin, s);
int len = s.length();
int n, c = 0; cin >> n;
for (int i = 0; i < len; i++) {
if (i < n && !c) {
s1 += s[i];
}
else if (i == n) {
c = 1;
s2 += s[i];
}
else
s2+= s[i];
}
cout << s1 << endl << s2;
return 0;
}
------------
//#include <iostream> // Implemented Known Memoiziation Version
//#define SIZE 47
//#define BOUND 2971215073;
//using namespace std;
//
//int term[SIZE];
//// 47th element
//
//int fib_i(int n) {
//
// if (n == 1) {
// return 0;
// }
//
// if (n == 2) {
// return 1;
// }
//
// if (term[n] != 0)
// return term[n];
// else {
// term[n] = fib_i(n - 1, i++) + fib_i(n - 2, i++);
// return term[n];
// }
//}
//
//int main()
//{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
//
// int i, n;
// cin >> n;
// cout << fib_i(n, i);
//
// return 0;
//}
#include <iostream>
#include <cmath>
//#include <climits>
#include <string>
//#include <algorithm>
using namespace std;
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
string s, s1 = "", s2 = "";
getline(cin, s);
int len = s.length();
int n, c = 0; cin >> n;
for (int i = 0; i < len; i++) {
if (i < n && !c) {
s1 += s[i];
}
else if (i == n) {
c = 1;
s2 += s[i];
}
else
s2+= s[i];
}
cout << s1 << endl << s2;
return 0;
}