葉林
Linked with GitHub
# 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'; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up