QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#643591#9307. Clock MastercastcWA 41ms5100kbC++201.4kb2024-10-15 22:12:052024-10-15 22:12:06

Judging History

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

  • [2024-10-15 22:12:06]
  • 评测
  • 测评结果:WA
  • 用时:41ms
  • 内存:5100kb
  • [2024-10-15 22:12:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define int long long
vector<int> minp, primes;

void sieve(int n) {
    minp.assign(n + 1, 0);
    primes.clear();
    
    for (int i = 2; i <= n; i++) {
        if (minp[i] == 0) {
            minp[i] = i;
            primes.push_back(i);
        }
        
        for (auto p : primes) {
            if (i * p > n) {
                break;
            }
            minp[i * p] = p;
            if (p == minp[i]) {
                break;
            }
        }
    }
}
const int N = 3e4 + 10;
ld dp[N];
ld lg[N];
void solve() {
    int n;
    cin >> n;
    cout << dp[n] << "\n";
}          
    
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(9) << "\n";
    for(int i = 1; i < N; i++) {
        lg[i] = log(i);
    }
    sieve(N);
    for(int i = 0; i < (int)primes.size(); i++) {
        for(int k = N - 1; k >= primes[i]; k--) {
            for(int j = primes[i]; j * primes[i] < N; j *= primes[i]) {
                if(k - j >= 0) {
                    dp[k] = max(dp[k], dp[k - j] + lg[j]);
                }
            }
        }
    }


    int T = 1;
    cin >> T;
    while(T--) solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 41ms
memory: 4988kb

input:

3
2
7
10

output:


0.693147181
2.484906650
3.401197382

result:

ok 3 numbers

Test #2:

score: -100
Wrong Answer
time: 39ms
memory: 5100kb

input:

5000
580
4555
4654
1420
53
1076
1226
2733
2285
348
2104
2293
3447
4208
710
307
1763
1142
3027
2151
3182
1546
3398
867
2380
830
4211
3117
3058
2251
1890
3961
4003
3991
4167
4976
1765
3235
2644
4070
4644
3645
875
3005
4769
4934
3846
2941
255
946
4164
1372
1193
3056
4472
508
3949
2473
4490
88
4014
2953...

output:


59.808521922
181.544766429
182.392064290
102.514787847
12.794858811
87.112177748
94.289632957
150.939424198
135.931424623
44.138273262
130.234331136
135.990701233
170.311792991
178.600327450
67.651984758
40.424701195
116.701483269
90.461792291
159.824415244
131.024777228
164.225018264
108.283079637...

result:

wrong answer 2nd numbers differ - expected: '202.4405258', found: '181.5447664', error = '0.1032193'