Submission #17225292
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;double f(const double P, const double x){return x + pow(2, -x / 1.5) * P;}int main(){double P;cin >> P;constexpr double c = 3 / log(4);if (P <= c) {cout << setprecision(10) << P << endl;return 0;}double left = 0;double right = P;double diff = right - left;while ((diff = right - left) > 1e-8) {
#include <bits/stdc++.h> using namespace std; double f(const double P, const double x) { return x + pow(2, -x / 1.5) * P; } int main() { double P; cin >> P; constexpr double c = 3 / log(4); if (P <= c) { cout << setprecision(10) << P << endl; return 0; } double left = 0; double right = P; double diff = right - left; while ((diff = right - left) > 1e-8) { double p1 = left + 1 * diff / 3; double p2 = left + 2 * diff / 3; if (f(P, p1) > f(P, p2)) left = p1; else right = p2; } cout << setprecision(10) << f(P, right) << endl; }
Submission Info
Submission Time | |
---|---|
Task | B - ムーアの法則 |
User | atug |
Language | C++ (GCC 9.2.1) |
Score | 100 |
Code Size | 652 Byte |
Status | AC |
Exec Time | 8 ms |
Memory | 4272 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 8 ms | 4084 KB |
02.txt | AC | 2 ms | 3712 KB |
03.txt | AC | 2 ms | 3804 KB |
04.txt | AC | 3 ms | 3660 KB |
05.txt | AC | 2 ms | 3580 KB |
06.txt | AC | 2 ms | 3748 KB |
07.txt | AC | 2 ms | 4120 KB |
08.txt | AC | 2 ms | 3780 KB |
09.txt | AC | 2 ms | 3576 KB |
10.txt | AC | 2 ms | 4120 KB |
11.txt | AC | 2 ms | 4176 KB |
12.txt | AC | 3 ms | 4208 KB |
13.txt | AC | 2 ms | 3932 KB |
14.txt | AC | 2 ms | 4052 KB |
15.txt | AC | 2 ms | 4124 KB |
16.txt | AC | 2 ms | 4104 KB |
17.txt | AC | 2 ms | 4076 KB |
18.txt | AC | 2 ms | 4148 KB |
19.txt | AC | 2 ms | 4100 KB |
20.txt | AC | 2 ms | 4212 KB |
21.txt | AC | 2 ms | 4072 KB |
22.txt | AC | 2 ms | 4000 KB |
23.txt | AC | 2 ms | 4088 KB |
24.txt | AC | 2 ms | 3860 KB |
25.txt | AC | 2 ms | 4100 KB |
sample_01.txt | AC | 2 ms | 4272 KB |
sample_02.txt | AC | 2 ms | 3648 KB |
sample_03.txt | AC | 3 ms | 4008 KB |