提交记录 8911


用户 题目 状态 得分 用时 内存 语言 代码长度
lastans7 noip17f. 【NOIP2017】列队 Wrong Answer 0 337.019 ms 57944 KB C++ 2.10 KB
提交时间 评测时间
2019-03-21 15:27:54 2020-08-01 01:26:20
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

#define P 998244353

using namespace std;

typedef long long ll;

int n, m, op;

vector <int> D[400010];

ll A[400010], B[400010], SB[400010], mu[400010], Smu[400010], lans = 0, ans = 0;

ll SV[400010], O[400010];

ll calc(ll x) {
    return x * (x + 1) / 2 % P;
}

int main() {
    //freopen("lalaland.in", "r", stdin);
    //freopen("lalaland.out", "w", stdout);
    n = 400000, m = 400000, op = 0;//scanf("%d%d%d", &n, &m, &op);
    for(int i = 1; i <= 400000; i++)
        for(int j = i; j <= 400000; j += i) O[j]++;
    for(int i = 1; i <= 400000; i++) D[i].resize(O[i]);
    for(int i = 1; i <= 400000; i++)
        for(int j = i; j <= 400000; j += i) D[j][--O[j]] = i;
    mu[1] = 1;
    for(int i = 1; i <= 400000; i++)
        for(int j = i + i; j <= 400000; j += i) mu[j] -= mu[i];
    for(int i = 1; i <= 400000; i++) {
        ll ans = 0;
        for(int j = 0; j < D[i].size(); j++) {
            int t = D[i][j];
            ans = (ans + mu[t] * calc(i / t) % P * t) % P;
        }
        A[i] = (A[i - 1] + i * ans * 2ll % P - (i == 1)) % P;
    }
    for(int i = 1; i <= 400000; i++) {
        ll ans = 0;
        for(int j = 0; j < D[i].size(); j++) {
            int t = D[i][j];
            Smu[t] += mu[i];
            ans = (ans + mu[t] * Smu[t] % P) % P;
        }
        B[i] = (B[i - 1] + mu[i] * ans * 2 - (i == 1)) % P;
    }
    for(int i = 1; i <= 400000; i++)
        for(int j = i; j <= 400000; j += i)
            SB[j] = (SB[j] + B[i] * mu[j / i]) % P;
    for(int i = 1; i <= 400000; i++) SV[i] = 1;
return 0;
    //for(int i = 1; i <= 400000; i++) ans = (ans + SV[i] * SB[i]) % P;
    for(int i = 1; i <= n; i++) {
        ll a;
        scanf("%lld", &a);
        if(op == 1) a = ((19891989ll * lans) + a) % m + 1;
        ll av = A[a];
        for(int j = 0; j < D[a].size(); j++) {
            int t = D[a][j];
            ll det = av * SV[t] % P;
            ans = (ans + det * SB[t]) % P;
            SV[t] = (SV[t] + det) % P;
        }
        if(op || i == n) printf("%lld\n", lans = (ans % P + P) % P); //!!!
    }
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1335.926 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #2336.14 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #3336.632 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #4336.964 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #5336.928 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #6336.626 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #7337.019 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #8336.638 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #9336.526 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #10335.632 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #11336.605 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #12336.23 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #13336.724 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #14336.612 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #15335.693 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #16336.75 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #17336.297 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #18336.691 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #19336.079 ms56 MB + 600 KBWrong AnswerScore: 0

Testcase #20335.547 ms56 MB + 600 KBWrong AnswerScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-05 15:07:11 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠