QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#696286 | #9307. Clock Master | Blizzard | RE | 0ms | 0kb | C++23 | 1.7kb | 2024-10-31 22:01:35 | 2024-10-31 22:01:40 |
answer
#include <bits/stdc++.h>
using namespace std;
//--------------------------------
// #define int long long
#define LL long long
// #define lc p << 1
// #define rc p << 1 | 1
#define lowbit(x) x & (-x)
#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++)
#define Blizzard ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
//-----------------------------------------
const int N = 3e4 + 10;
double f[N];
double a[N];
int pri[N], vis[N * 10 + 32];
int cnt;
void inti()
{
for (int i = 1; i <= N; i++)
{
a[i] = log(i);
}
for (int i = 2; i < N * 10; i++)
{
if (!vis[i])
{
vis[i] = 1;
pri[++cnt] = i;
}
for (int j = 1; j <= cnt && 1LL * i * pri[j] <= N; j++)
{
vis[i * pri[j]] = 1;
if (i % pri[j] == 0)
break;
}
}
// for (int i = 1; i <= 10; i++)
// cout << pri[i] << " \n"[i == 10];
// cout << cnt << '\n';
for (int i = 1; i <= cnt; i++)
{
for (int j = N - 3; j >= pri[i]; j--)
{
for (int k = pri[i]; k <= j; k *= pri[i])
{
f[j] = max(f[j], f[j - k] + a[k]);
}
}
}
}
void solve()
{
int x;
cin >> x;
cout << fixed << setprecision(10) << f[x] << '\n';
}
signed main()
{
// freopen("in.txt", "r", stdin);
// freopen("out.out", "w", stdout);
Blizzard; // false
int t = 1;
cin >> t;
inti();
while (t--)
solve();
return 0;
}
/*
while (l < r)
{
int mid = l + r >> 1;
if (check(mid)) r = mid;
else l = mid + 1;
}
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
3 2 7 10