QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#346651#3853. Lines in a gridKirill22#WA 732ms238084kbC++231.1kb2024-03-08 20:32:312024-03-08 20:32:32

Judging History

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

  • [2024-03-08 20:32:32]
  • 评测
  • 测评结果:WA
  • 用时:732ms
  • 内存:238084kb
  • [2024-03-08 20:32:31]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

const int N = (int) 1e7 + 22, mod = (int) 1e6 + 3;
int L[N], L1[N], R1[N], R2[N], e[N], phi[N];

int get(int n) {
    return phi[n];
}

void upd(int& x) {
    x = (x % mod + mod) % mod;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    iota(phi, phi + N, 0);
    for (int i = 1; i < N; i++) {
        for (int j = i + i; j < N; j += i) {
            phi[j] -= phi[i];
        }
    }
    for (int n = 1; n < N; n++) {
        e[n] = (n % 2 == 0 ? 0 : get((n - 1) / 2));
        upd(e[n]);
        if (n > 1) R1[n] = R1[n - 1] + 4 * (get(n - 1) - e[n]);
        upd(R1[n]);
        R2[n] = (n % 2 == 0 ? (n - 1) * get(n - 1) : (n % 4 == 1 ? (n - 1) * get(n - 1) / 2 : 0));
        upd(R2[n]);
        if (n > 1) L1[n] = 2 * L[n - 1] - L1[n - 1] + R2[n];
        upd(L1[n]);
        L[n] = 2 * L1[n] - L[n - 1] + R1[n];
        upd(L[n]);
    }
    int q;
    cin >> q;
    while (q--) {
        int n;
        cin >> n;
        cout << L[n] << '\n';
    }
}

详细

Test #1:

score: 100
Accepted
time: 706ms
memory: 238080kb

input:

10
1 2 3 4 5 6 7 8 9 10

output:

0
6
20
62
140
306
536
938
1492
2306

result:

ok 10 lines

Test #2:

score: 0
Accepted
time: 706ms
memory: 238004kb

input:

100
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

output:

0
6
20
62
140
306
536
938
1492
2306
3296
4722
6460
8830
11568
14946
18900
23926
29544
36510
44388
53586
63648
75674
88948
104374
121032
139966
160636
184466
209944
239050
270588
305478
342480
383370
427020
475830
527280
583338
642900
708798
777912
854022
934604
21071
111365
209991
313609
425767
5425...

result:

ok 100 lines

Test #3:

score: -100
Wrong Answer
time: 732ms
memory: 238084kb

input:

1000
999000 999001 999002 999003 999004 999005 999006 999007 999008 999009 999010 999011 999012 999013 999014 999015 999016 999017 999018 999019 999020 999021 999022 999023 999024 999025 999026 999027 999028 999029 999030 999031 999032 999033 999034 999035 999036 999037 999038 999039 999040 999041 9...

output:

372179
72149
335817
477612
199447
217900
582090
944307
439811
223579
741409
90418
927165
855901
616113
692035
711256
386756
693739
537155
439307
6758
586710
906960
39568
7939
514740
290607
526419
512473
999338
930584
641998
707749
552551
577951
646870
456465
187661
668085
12962
762486
248794
473696
...

result:

wrong answer 1st lines differ - expected: '546070', found: '372179'