Submission #17225292
Source Code Expand
#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 KiB |
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 KiB |
| 02.txt | AC | 2 ms | 3712 KiB |
| 03.txt | AC | 2 ms | 3804 KiB |
| 04.txt | AC | 3 ms | 3660 KiB |
| 05.txt | AC | 2 ms | 3580 KiB |
| 06.txt | AC | 2 ms | 3748 KiB |
| 07.txt | AC | 2 ms | 4120 KiB |
| 08.txt | AC | 2 ms | 3780 KiB |
| 09.txt | AC | 2 ms | 3576 KiB |
| 10.txt | AC | 2 ms | 4120 KiB |
| 11.txt | AC | 2 ms | 4176 KiB |
| 12.txt | AC | 3 ms | 4208 KiB |
| 13.txt | AC | 2 ms | 3932 KiB |
| 14.txt | AC | 2 ms | 4052 KiB |
| 15.txt | AC | 2 ms | 4124 KiB |
| 16.txt | AC | 2 ms | 4104 KiB |
| 17.txt | AC | 2 ms | 4076 KiB |
| 18.txt | AC | 2 ms | 4148 KiB |
| 19.txt | AC | 2 ms | 4100 KiB |
| 20.txt | AC | 2 ms | 4212 KiB |
| 21.txt | AC | 2 ms | 4072 KiB |
| 22.txt | AC | 2 ms | 4000 KiB |
| 23.txt | AC | 2 ms | 4088 KiB |
| 24.txt | AC | 2 ms | 3860 KiB |
| 25.txt | AC | 2 ms | 4100 KiB |
| sample_01.txt | AC | 2 ms | 4272 KiB |
| sample_02.txt | AC | 2 ms | 3648 KiB |
| sample_03.txt | AC | 3 ms | 4008 KiB |