Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- const int maxn = 1000 + 100;
- int n, ans;
- double p, mn;
- int main() {
- #ifdef ExRoc
- freopen("test.txt", "r", stdin);
- #endif // ExRoc
- ios::sync_with_stdio(false);
- cin >> n >> p;
- mn = n;
- ans = 1;
- for (int i = 2; i <= n; ++i) {
- if (n % i == 0) {
- double tmp = n / i + n * (1 - pow(1 - p, i));
- if (tmp < mn) {
- ans = i;
- mn = tmp;
- }
- }
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement