UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213074#2348. Lifewucy10010371ms104972kbC++824b2024-11-09 19:09:502024-11-09 23:05:49

answer

#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int l,q;
map <int,int> f;
int fun(int x) {
	int ls = -l,rs = l;
	while(ls <= rs) {
		int mid = (ls + rs) / 2;
		int now = mid * mid * mid;
		if(now < x) ls = mid + 1;
		else if(now == x) return mid;
		else rs = mid - 1;
	}
	return 0;
}
int main() {
	cin >> l >> q;
	for(int a = -l;a <= l;a ++) {
		for(int b = -l;b <= l;b ++) {
			int x = a * a * a + b * b * b;
			f[x] = a + l + 1;			
		} 
	}
	while(q --){
		int x;
		cin >> x;
		for(int c = 0;c <= l;c ++) {
			int m = f[x - c * c * c];
			if(m) {
				m = m - l - 1;
				int n = fun(x - c * c * c - m * m * m);
				cout << m << " " << n << " " << c << endl;
				x = 114514;
				break;
			}
		} 
		if(x != 114514)
		cout << l + 1 << " " << l + 1 << " " << l + 1 << endl;
	}
} 

详细

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

Test #1:

score: 10
Accepted
time: 5ms
memory: 2124kb

input:

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

output:

14 -1 14
16 -13 0
-21 -30 34
24 -22 13
16 -12 0
11 11 11
64 -77 58
31 -28 12
17 -13 16
-8 -11 14

result:

ok Correct!


Test #2:

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

input:

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

output:

100 100 100
100 100 100
17 -5 14
15 -7 8
50 -58 42
7 1 1
12 -11 5
21 -11 8
-12 -24 28
52 -51 2

result:

ok Correct!


Test #3:

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

input:

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

output:

99 99 99
99 99 99
21 5 2
-24 -27 35
31 -29 15
26 -22 3
-8 -9 21
19 -14 10
12 -11 1
14 10 3

result:

ok Correct!


Test #4:

score: 10
Accepted
time: 97ms
memory: 5652kb

input:

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

output:

-21 -26 30
25 -21 0
12 8 7
-6 -27 30
18 -8 0
-4 -13 14
92 92 92
19 -18 1
13 -11 7
-35 -52 57
18 -6 1...

result:

ok Correct!


Test #5:

score: 10
Accepted
time: 130ms
memory: 5548kb

input:

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

output:

42 -44 26
21 -8 3
15 -12 4
14 -10 1
22 -20 13
15 -4 3
7 0 0
15 -6 2
-1 -13 22
13 7 6
92 92 92
15 10 ...

result:

ok Correct!


Test #6:

score: 10
Accepted
time: 111ms
memory: 5784kb

input:

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

output:

6 -5 0
19 -1 3
20 -4 7
-4 -4 8
17 -11 12
14 5 2
16 -5 8
20 -18 2
-4 -10 11
96 96 96
43 -42 3
50 -49 ...

result:

ok Correct!


Test #7:

score: 10
Accepted
time: 2348ms
memory: 97060kb

input:

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

output:

13 -4 3
27 -22 9
12 7 2
16 8 2
28 -24 11
-8 -16 21
17 -9 6
-150 -234 253
-96 -96 121
21 -13 5
14 9 9...

result:

ok Correct!


Test #8:

score: 10
Accepted
time: 2560ms
memory: 103500kb

input:

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

output:

-8 -14 18
-7 -37 38
17 15 4
15 -4 0
-6 -11 22
17 -1 7
43 -42 1
-7 -8 10
20 -9 5
24 -20 6
380 -391 17...

result:

ok Correct!


Test #9:

score: 10
Accepted
time: 2536ms
memory: 104972kb

input:

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

output:

13 -2 0
21 -8 2
29 -27 5
29 -31 23
13 -11 5
13 -2 3
422 -447 242
22 -14 4
27 -26 17
41 -39 7
11 -7 0...

result:

ok Correct!


Test #10:

score: 10
Accepted
time: 2578ms
memory: 103348kb

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
10 4 1
21 -20 0
823 -833 274
34 -37 24
45 -56 44
21 -6 4
23 -19 16
34 -42 33
18 -13 9
111...

result:

ok Correct!


Extra Test:

score: 0
Extra Test Passed