提交记录 8912


用户 题目 状态 得分 用时 内存 语言 代码长度
lastans7 noip17f. 【NOIP2017】列队 Wrong Answer 0 589.704 ms 64348 KB C++ 2.16 KB
提交时间 评测时间
2019-03-21 15:28:31 2020-08-01 01:26:29
#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);
    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;*/
    for(int i = 1; i <= 400000; i++)
        for(int j = i; j <= 400000; j += i) D[j].push_back(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;
    //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 #1450.231 ms60 MB + 60 KBWrong AnswerScore: 0

Testcase #2450.405 ms60 MB + 60 KBWrong AnswerScore: 0

Testcase #3450.308 ms60 MB + 60 KBWrong AnswerScore: 0

Testcase #4450.322 ms60 MB + 60 KBWrong AnswerScore: 0

Testcase #5449.832 ms60 MB + 60 KBWrong AnswerScore: 0

Testcase #6450.254 ms60 MB + 60 KBWrong AnswerScore: 0

Testcase #7464.392 ms60 MB + 496 KBWrong AnswerScore: 0

Testcase #8464.543 ms60 MB + 492 KBWrong AnswerScore: 0

Testcase #9467.613 ms60 MB + 532 KBWrong AnswerScore: 0

Testcase #10465.104 ms60 MB + 484 KBWrong AnswerScore: 0

Testcase #11449.975 ms60 MB + 52 KBWrong AnswerScore: 0

Testcase #12450.058 ms60 MB + 52 KBWrong AnswerScore: 0

Testcase #13449.952 ms60 MB + 52 KBWrong AnswerScore: 0

Testcase #14449.956 ms60 MB + 52 KBWrong AnswerScore: 0

Testcase #15565.944 ms62 MB + 672 KBWrong AnswerScore: 0

Testcase #16567.001 ms62 MB + 716 KBWrong AnswerScore: 0

Testcase #17491.898 ms60 MB + 992 KBWrong AnswerScore: 0

Testcase #18490.404 ms60 MB + 984 KBWrong AnswerScore: 0

Testcase #19580.293 ms62 MB + 748 KBWrong AnswerScore: 0

Testcase #20589.704 ms62 MB + 860 KBWrong AnswerScore: 0


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