Skip to content

Commit 2465cd8

Browse files
snail wanna go up is done
1 parent e89d827 commit 2465cd8

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

2869_snail_wanna_go/a.out

17.1 KB
Binary file not shown.

2869_snail_wanna_go/main.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
// input_data[0]: the distance a snail goes up in daytime.
5+
// input_data[1]: the distance the snail slep down at night.
6+
// input_data[2]: the distance the snail need to go up.
7+
8+
int* get_input() {
9+
int* data = new int[3];
10+
for (int i = 0; i < 3; ++i)
11+
cin >> data[i];
12+
return data;
13+
}
14+
15+
int calculate_date(int* data) {
16+
int ans = (data[2] - data[0]) / (data[0] - data[1]) + (((data[2] - data[0]) % (data[0] - data[1]) == 0) ? 0 : 1) + 1;
17+
delete [] data;
18+
return ans;
19+
}
20+
21+
void printInt(int message) {
22+
cout << message << '\n';
23+
}
24+
25+
int main() {
26+
printInt(calculate_date(get_input()));
27+
return 0;
28+
}

0 commit comments

Comments
 (0)