QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#668146 | #9307. Clock Master | 4eyebird# | TL | 0ms | 0kb | C++17 | 1.1kb | 2024-10-23 11:53:57 | 2024-10-23 11:53:59 |
answer
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
const int N = 30005;
#define Buff ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define int long long
int primes[N], cnt;
bool st[N];
double ans[N];
void pr()
{
st[0] = st[1] = 1;
for (int i = 2; i <= N - 2; i++)
{
if (!st[i])
{
primes[++cnt] = i;
for (int j = 1; j <= cnt && i * primes[j] <= N - 2; j++)
{
st[primes[j] * i] = true;
if (i % primes[j] == 0) break;
}
}
}
}
void init()
{
for (int i = 1; i <= cnt; i++)
{
for (int j = 30000; j >= primes[i]; j--)
{
for (int k = primes[i]; k <= j; k *= primes[i])
{
ans[j] = max(ans[j], ans[j - k] + log(k));
}
}
}
}
void solve()
{
int n;
cin >> n;
cout << fixed << setprecision(10) << ans[n] << "\n";
}
signed main()
{
Buff;
int _T_ = 1;
cin >> _T_;
pr();
init();
while (_T_--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
3 2 7 10