ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#184722 | #2348. Life | wosile | 100 | 1337ms | 32688kb | C++ | 978b | 2023-09-12 10:46:25 | 2023-09-12 12:06:47 |
answer
#include<bits/stdc++.h>
using namespace std;
pair<int,int> sum[4000005];
int a[10005],b[10005],c[10005];
map<int,int>mp;
int main(){
int L,q;
scanf("%d%d",&L,&q);
int cnt=0;
for(int i=-L;i<=L;i++)mp[i*i*i]=i;
for(int i=-L;i<=L;i++)for(int j=-L;j<=L;j++)if(abs(i*i*i+j*j*j)<=1e9+1e5){
cnt++;
sum[cnt].first=i*i*i+j*j*j;
sum[cnt].second=i;
}
sort(sum+1,sum+cnt+1);
cnt=unique(sum+1,sum+cnt+1)-sum-1;
for(int i=1;i<=10000;i++)a[i]=b[i]=c[i]=L+1;
int l=1,r=0;
// printf("pr1\n");
for(int i=L;i>=-L;i--){
while(r<cnt && sum[r+1].first<=-i*i*i+10000)r++;
while(l<=cnt && sum[l].first<=-i*i*i)l++;
for(int j=l;j<=r;j++){
// printf("%d %d\n",i,sum[j]);
}
for(int j=l;j<=r;j++)a[sum[j].first+i*i*i]=i,b[sum[j].first+i*i*i]=sum[j].second;
}
for(int i=1;i<=10000;i++){
if(a[i]<=L)c[i]=mp[i-a[i]*a[i]*a[i]-b[i]*b[i]*b[i]];
}
while(q--){
int x;
scanf("%d",&x);
printf("%d %d %d\n",a[x],b[x],c[x]);
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 4ms
memory: 32600kb
input:
98 10 5487 1899 3043 5373 2368 3993 723 9567 6812 901
output:
-46 47 -10 -77 72 44 -36 42 -29 -72 66 45 -12 16 0 -55 44 44 -77 64 58 -28 31 12 -66 65 27 -11 14 -8
result:
ok Correct!
Test #2:
score: 10
Accepted
time: 8ms
memory: 32604kb
input:
99 10 6139 3749 7532 3544 3976 345 522 8442 6400 7965
output:
100 100 100 100 100 100 -12 21 -1 -49 57 -40 -58 50 42 1 7 1 -11 12 5 -84 89 -47 -24 28 -12 -51 52 2
result:
ok Correct!
Test #3:
score: 10
Accepted
time: 7ms
memory: 32600kb
input:
98 10 5078 9597 9394 9368 8777 6955 8020 5115 398 3771
output:
99 99 99 99 99 99 2 21 5 -42 44 -12 -44 46 -15 -60 59 26 -9 21 -8 -14 19 10 -32 31 15 -18 19 14
result:
ok Correct!
Test #4:
score: 10
Accepted
time: 11ms
memory: 32604kb
input:
91 10000 163 6364 2583 7101 5320 483 6442 1028 1209 1710 5617 296 7228 1593 4580 5559 9699 2015 6397...
output:
-76 91 -68 -39 43 -24 -7 13 9 -27 30 -6 -84 82 36 -13 14 -4 92 92 92 -60 55 37 -11 13 7 -52 57 -35 -...
result:
ok Correct!
Test #5:
score: 10
Accepted
time: 11ms
memory: 32604kb
input:
91 10000 6480 8776 1711 1745 4845 3338 343 3167 8450 2756 2252 4375 4912 9822 8053 1533 1216 4161 61...
output:
-84 87 -39 -77 62 61 -54 58 -33 -27 23 21 -20 22 13 -19 20 13 -91 91 7 -20 23 -10 -37 39 -6 6 13 7 9...
result:
ok Correct!
Test #6:
score: 10
Accepted
time: 13ms
memory: 32600kb
input:
95 10000 91 6885 8279 384 5310 2877 4483 2176 267 393 5446 7415 3853 4223 8480 3368 6752 9898 5779 7...
output:
-5 6 0 -86 69 68 -58 63 -36 -52 62 -46 -11 17 12 2 14 5 -48 51 -26 -24 20 20 -10 11 -4 96 96 96 -42 ...
result:
ok Correct!
Test #7:
score: 10
Accepted
time: 288ms
memory: 32680kb
input:
952 10000 2160 9764 2079 4616 9459 4653 4400 6373 2089 7189 4202 4497 6684 119 1191 2206 9287 5365 1...
output:
-102 82 80 -666 633 347 -631 667 -357 -748 802 -460 -24 28 11 -88 90 -35 -30 26 24 -234 253 -150 -44...
result:
ok Correct!
Test #8:
score: 10
Accepted
time: 303ms
memory: 32688kb
input:
992 10000 2576 3876 8352 3311 9101 5255 5420 145 7396 6040 8529 9794 5164 4302 7147 3683 152 1136 79...
output:
-302 252 226 -190 173 119 -874 909 -437 -855 903 -481 -488 501 -212 -821 803 329 -42 43 1 -8 10 -7 -...
result:
ok Correct!
Test #9:
score: 10
Accepted
time: 375ms
memory: 32684kb
input:
996 10000 2189 8757 4831 6765 991 2216 9313 7968 7020 9945 988 9422 7315 2132 2333 5962 1798 8184 22...
output:
-2 13 0 -300 301 -64 -97 96 32 -31 29 23 -872 712 671 -638 642 -170 -447 422 242 -20 25 7 -663 698 -...
result:
ok Correct!
Test #10:
score: 10
Accepted
time: 317ms
memory: 32684kb
input:
988 10000 1785 1065 1261 3054 2475 693 9109 9404 1153 4364 1847 8539 4364 9471 6183 6855 303 306 635...
output:
-23 28 -20 -200 184 121 -439 517 -377 -833 823 274 -197 180 122 -742 702 397 -292 277 154 -41 44 -19...
result:
ok Correct!
Extra Test:
score: 0
Extra Test Passed