You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
double k;
|
|
double x = 2.0; // x代表上一步走的距离
|
|
double s = 2.0; //已经走过的距离是2
|
|
int n = 1; //表示已经走完第1步
|
|
int main() {
|
|
cin >> k; //要走多远
|
|
while (true) {
|
|
n++;
|
|
x *= 0.98; //每次是在上一步距离上 * 0.98
|
|
s += x; //累加距离
|
|
if (s >= k) { //达标
|
|
cout << n << endl;
|
|
break;
|
|
}
|
|
}
|
|
}
|