QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#668146#9307. Clock Master4eyebird#TL 0ms0kbC++171.1kb2024-10-23 11:53:572024-10-23 11:53:59

Judging History

你现在查看的是最新测评结果

  • [2024-10-23 11:53:59]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-10-23 11:53:57]
  • 提交

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

output:


result: