Files
exercises/pojcs101_E01003.cpp
2026-07-24 09:24:21 +08:00

31 lines
600 B
C++

#include <iostream>
#include <vector>
static std::vector<double> max_lengths;
static void init() {
double length = 0;
for (int i = 2; length < 5.5; i++) {
max_lengths.push_back(length);
length += 1.0 / i;
}
}
int main() {
init();
double target_length = 0;
for (;;) {
std::cin >> target_length;
if (target_length == 0) { break; }
for (int i = 0;; i++) {
if (max_lengths[i] > target_length) {
std::cout << i << " card(s)" << std::endl;
break;
}
}
}
return 0;
}