# ZeroJudge - f728: 生日問題 ### 題目連結:https://zerojudge.tw/ShowProblem?problemid=f728 ###### tags: `ZeroJudge` `數學` `機率` ```cpp= #include <iostream> #include <algorithm> using namespace std; double odds[366] = { 1 }; void Initialize() { for (int i = 1; i <= 365; ++i) odds[i] = odds[i - 1] * (365 - i + 1) / 365; for (int i = 1; i <= 365; ++i) odds[i] = 1 - odds[i]; } int main() { cin.sync_with_stdio(false); cin.tie(nullptr); Initialize(); int bound; while (cin >> bound) cout << (bound == 100 ? 366 : int(lower_bound(odds + 2, odds + 365, bound / 100.0) - odds)) << '\n'; } ```