UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213114#2348. LifeKXG1007583ms78820kbC++111.1kb2024-11-09 20:15:582024-11-09 23:13:13

answer

#include <cstdio>
#include <vector>
using namespace std;
const int mod = 923239;
vector<pair<int, int> > v[1000010];
long long l, q, x;
long long calc(long long x) {
    return x * x * x;
}
int main() {
    scanf("%lld%lld", &l, &q);
    for (int i = -l; i <= l; i++) {
        for (int j = -l; j <= l; j++) {
            v[((calc(i) + calc(j)) % mod + mod) % mod].push_back({i, j});
        }
    }
    for (int i = 1; i <= q; i++) {
        scanf("%lld", &x);
        int a = l + 1, b = l + 1, c = l + 1;
        for (int j = -l; j <= l; j++) {
            long long sub = ((x - calc(j)) % mod + mod) % mod;
            for (vector<pair<int, int> >::iterator it = v[sub].begin(); it != v[sub].end(); it++) {
                if (calc(it->first) + calc(it->second) + calc(j) == x) {
                    a = it->first;
                    b = j;
                    c = it->second;
                    break;
                }
            }
            if (a != l + 1) break;
        }
        printf("%d %d %d\n", a, b, c);
    }
    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 12ms
memory: 25104kb

input:

98 10
5487
1899
3043
5373
2368
3993
723
9567
6812
901

output:

-10 -46 47
44 -77 72
-29 -36 42
45 -72 66
0 -12 16
44 -55 44
58 -77 64
12 -28 31
27 -66 65
-8 -11 14

result:

ok Correct!


Test #2:

score: 10
Accepted
time: 3ms
memory: 25116kb

input:

99 10
6139
3749
7532
3544
3976
345
522
8442
6400
7965

output:

100 100 100
100 100 100
-1 -12 21
-40 -49 57
42 -58 50
1 1 7
5 -11 12
-47 -84 89
-12 -24 28
2 -51 52

result:

ok Correct!


Test #3:

score: 10
Accepted
time: 4ms
memory: 25108kb

input:

98 10
5078
9597
9394
9368
8777
6955
8020
5115
398
3771

output:

99 99 99
99 99 99
5 2 21
-12 -42 44
-15 -44 46
26 -60 59
-8 -9 21
10 -14 19
15 -32 31
14 -18 19

result:

ok Correct!


Test #4:

score: 10
Accepted
time: 20ms
memory: 25024kb

input:

91 10000
163
6364
2583
7101
5320
483
6442
1028
1209
1710
5617
296
7228
1593
4580
5559
9699
2015
6397...

output:

-68 -76 91
-24 -39 43
9 -7 13
-6 -27 30
36 -84 82
-4 -13 14
92 92 92
37 -60 55
7 -11 13
-35 -52 57
-...

result:

ok Correct!


Test #5:

score: 10
Accepted
time: 23ms
memory: 25020kb

input:

91 10000
6480
8776
1711
1745
4845
3338
343
3167
8450
2756
2252
4375
4912
9822
8053
1533
1216
4161
61...

output:

-39 -84 87
61 -77 62
-33 -54 58
21 -27 23
13 -20 22
13 -19 20
7 -91 91
-10 -20 23
-6 -37 39
7 6 13
9...

result:

ok Correct!


Test #6:

score: 10
Accepted
time: 29ms
memory: 25068kb

input:

95 10000
91
6885
8279
384
5310
2877
4483
2176
267
393
5446
7415
3853
4223
8480
3368
6752
9898
5779
7...

output:

0 -5 6
68 -86 69
-36 -58 63
-46 -52 62
12 -11 17
5 2 14
-26 -48 51
20 -24 20
-4 -10 11
96 96 96
3 -4...

result:

ok Correct!


Test #7:

score: 10
Accepted
time: 1877ms
memory: 74276kb

input:

952 10000
2160
9764
2079
4616
9459
4653
4400
6373
2089
7189
4202
4497
6684
119
1191
2206
9287
5365
1...

output:

80 -102 82
347 -666 633
-357 -631 667
-460 -748 802
11 -24 28
-35 -88 90
24 -30 26
-150 -234 253
186...

result:

ok Correct!


Test #8:

score: 10
Accepted
time: 1882ms
memory: 78408kb

input:

992 10000
2576
3876
8352
3311
9101
5255
5420
145
7396
6040
8529
9794
5164
4302
7147
3683
152
1136
79...

output:

226 -302 252
119 -190 173
-437 -874 909
-481 -855 903
-212 -488 501
329 -821 803
1 -42 43
-7 -8 10
5...

result:

ok Correct!


Test #9:

score: 10
Accepted
time: 1895ms
memory: 78820kb

input:

996 10000
2189
8757
4831
6765
991
2216
9313
7968
7020
9945
988
9422
7315
2132
2333
5962
1798
8184
22...

output:

0 -2 13
-64 -300 301
32 -97 96
23 -31 29
671 -872 712
-170 -638 642
242 -447 422
7 -20 25
-365 -663 ...

result:

ok Correct!


Test #10:

score: 10
Accepted
time: 1838ms
memory: 77984kb

input:

988 10000
1785
1065
1261
3054
2475
693
9109
9404
1153
4364
1847
8539
4364
9471
6183
6855
303
306
635...

output:

-20 -23 28
121 -200 184
-377 -439 517
274 -833 823
122 -197 180
397 -742 702
154 -292 277
-19 -41 44...

result:

ok Correct!


Extra Test:

score: 0
Extra Test Passed