QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#413558#7046. Function!MCdycWA 3ms3656kbC++172.0kb2024-05-17 18:39:472024-05-17 18:39:47

Judging History

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

  • [2024-05-17 18:39:47]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3656kb
  • [2024-05-17 18:39:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
const int mod = 998244353;

int in2;
int in6;

void INFACT2()
{
    int x = 2;
    int p = 998244353 - 2LL;
    int res = 1;

    while (p > 0)
    {

        if (p % 2 == 1)
            res = res * x % mod;
        x = x * x % mod;
        p /= 2;
    }

    in2 = res;
}

void INFACT6()
{
    int x = 6;
    int p = 998244353LL - 2LL;
    int res = 1;

    while (p > 0)
    {

        if (p % 2 == 1)
            res = res * x % mod;
        x = x * x % mod;
        p /= 2;
    }

    in6 = res;
}

int solve()
{
    int n;
    cin >> n;

    int ans = 0;
    int bottom = 1;
    for (int i = 2; i * i <= n; i++)
    {
        bottom = i;

        int buffer = 0;
        int t = i;
        int cnt = 1;
        while (t <= n)
        {
            buffer += (min(t * i, n + 1) - t) * cnt % mod;
            t *= i;
            cnt++;
        }
        buffer %= mod;
        ans += buffer * i % mod;
        ans %= mod;
    }

    int i = bottom + 1;
    // int b = (n + 1) % mod * (i * (n - i + 1) % mod + (n - i + 1) % mod * (n - i) % mod * in2 % mod) -
    //         n % mod * (n + 1) % mod * (2 * n + 1) % mod * in6 % mod + (i - 1) * i % mod * (2 * i - 1) % mod * in6 %
    //         mod;
    // cout << b << '\n';
    if (i <= n)
    {
        ans += (n + 1) % mod * (i * (n - i + 1) % mod + (n - i + 1) % mod * (n - i) % mod * in2 % mod) % mod -
               n % mod * (n + 1) % mod * (2 * n + 1) % mod * in6 % mod +
               (i - 1) * i % mod * (2 * i - 1) % mod * in6 % mod;
        ans = (ans % mod + mod) % mod;
        cout << ans << '\n';
    }

    return 0;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int test = 1;
    INFACT2();
    INFACT6();
    // cin >> test;
    while (test--)
    {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3616kb

input:

2

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

10

output:

236

result:

ok 1 number(s): "236"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

20

output:

1646

result:

ok 1 number(s): "1646"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

27

output:

3862

result:

ok 1 number(s): "3862"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

37

output:

9571

result:

ok 1 number(s): "9571"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

100

output:

175028

result:

ok 1 number(s): "175028"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

123

output:

322744

result:

ok 1 number(s): "322744"

Test #8:

score: 0
Accepted
time: 1ms
memory: 3540kb

input:

2548

output:

765669726

result:

ok 1 number(s): "765669726"

Test #9:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

12448

output:

159637196

result:

ok 1 number(s): "159637196"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

65535

output:

120089112

result:

ok 1 number(s): "120089112"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

102458

output:

475774506

result:

ok 1 number(s): "475774506"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

222333

output:

64337543

result:

ok 1 number(s): "64337543"

Test #13:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

485174

output:

312492357

result:

ok 1 number(s): "312492357"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

685479

output:

35530508

result:

ok 1 number(s): "35530508"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

1025481

output:

921523794

result:

ok 1 number(s): "921523794"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

9999999

output:

732610409

result:

ok 1 number(s): "732610409"

Test #17:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

7458658

output:

825346623

result:

ok 1 number(s): "825346623"

Test #18:

score: 0
Accepted
time: 1ms
memory: 3532kb

input:

5268475

output:

30938162

result:

ok 1 number(s): "30938162"

Test #19:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

2658478

output:

780038100

result:

ok 1 number(s): "780038100"

Test #20:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

10000000

output:

679483439

result:

ok 1 number(s): "679483439"

Test #21:

score: 0
Accepted
time: 1ms
memory: 3540kb

input:

100000000

output:

498142384

result:

ok 1 number(s): "498142384"

Test #22:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

1000000000

output:

69187994

result:

ok 1 number(s): "69187994"

Test #23:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

10000000000

output:

23566211

result:

ok 1 number(s): "23566211"

Test #24:

score: -100
Wrong Answer
time: 3ms
memory: 3548kb

input:

100000000000

output:

25877103

result:

wrong answer 1st numbers differ - expected: '247411531', found: '25877103'