ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#198993 | #3463. 最大区间 | shiruiheng | 100 | 5212ms | 204376kb | C++ | 902b | 2023-12-03 11:32:26 | 2023-12-03 12:24:34 |
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k, a[1000010], st[1000010][22], ans[1000010];
#define fi first
#define se second
#define pi pair<ll, ll>
priority_queue<pi> q;
ll len[1000010];
long long query(int l, int r){
int s = __lg(r - l + 1);
return __gcd(st[l][s], st[r - (1 << s) + 1][s]);
}
int main()
{
scanf("%lld%lld", &n, &k);
for(int i = 1 ; i <= n ; i++){
scanf("%lld", a + i);
st[i][0] = a[i];
}
/*
for(int i = 1 ; i <= __lg(n) ; i++){
for(int j = 1 ; j + (1 << i) - 1 <= n ; j++)
st[j][i] = __gcd(st[j][i - 1], st[j + (1 << i - 1)][i - 1]);
}
//*/
for(int i = 1 ; i <= n ; i++){
len[i] = i;
q.push({a[i], i});
}
for(int i = 1 ; i <= k ; i++){
pi u = q.top();
q.pop();
printf("%lld\n", u.fi);
if(len[u.se] == n)
continue;
q.push({__gcd(u.fi, a[++len[u.se]]), u.se});
}
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 74ms
memory: 1464kb
input:
1000 500500 316229930 195440845 285 190 173850 107445 48194844915 29786052240 3470662866825 21449876...
output:
26383670221365600 16306004944772400 8332780503682635 7971077017640880 7253015614619775 5149941572068...
result:
ok 500500 lines
Test #2:
score: 10
Accepted
time: 72ms
memory: 1460kb
input:
1000 500500 10 5 45 30 3705 2280 452880675 279895650 18411000 11378625 13430625 8300625 6940498125 4...
output:
13694362219137600 12805411076655120 12463020406156320 8463581305679500 7914179285287275 770257021348...
result:
ok 500500 lines
Test #3:
score: 10
Accepted
time: 78ms
memory: 1464kb
input:
1000 500500 2571145 1589055 7945275 4910450 3557450 2198625 75348000 46567625 4922125 3042000 940062...
output:
36372051035345025 22479163780389030 13119152823571600 10459936245458700 8108082348571400 74488088766...
result:
ok 500500 lines
Test #4:
score: 10
Accepted
time: 477ms
memory: 21640kb
input:
100000 1000000 269019726702209411 974764215496813081 547920080673102149 403277729561219907 575984909...
output:
999997745191855356 999963005393234573 999926113482756345 999922932458629212 999873551825672168 99986...
result:
ok 1000000 lines
Test #5:
score: 10
Accepted
time: 312ms
memory: 21636kb
input:
100000 1000000 269845965585325539 410993175365329221 287854792412106895 411389931291882089 384766635...
output:
999984587617809411 999982422426861182 999977862966742257 999962389243327312 999960196509914341 99995...
result:
ok 1000000 lines
Test #6:
score: 10
Accepted
time: 310ms
memory: 21640kb
input:
100000 1000000 270672213058376259 847222126643910770 251161541005887448 196130104757703054 970176324...
output:
999969088094752736 999950043867991957 999942757941147478 999938229401659037 999937972040991874 99993...
result:
ok 1000000 lines
Test #7:
score: 10
Accepted
time: 925ms
memory: 204376kb
input:
1000000 1000000 445 275 2160 1335 9345 5775 1969065 1216950 2742977370 1695253245 1295058240 8003900...
output:
975897643491928749 967909511887184303 957662363896634201 937776145086931820 935483120267844976 93449...
result:
ok 1000000 lines
Test #8:
score: 10
Accepted
time: 838ms
memory: 204372kb
input:
1000000 1000000 120789085 74651760 373258800 230686625 3751250 2318400 437094650 270139350 72250 433...
output:
989440590200479888 979442127462649963 962123363113843633 949234663940571975 922027929185254986 91132...
result:
ok 1000000 lines
Test #9:
score: 10
Accepted
time: 1171ms
memory: 204372kb
input:
1000000 1000000 511670775 316229930 275 165 1493195 922845 24310 12155 3843774799150 2375583470975 4...
output:
993470386599911223 982929594264450702 981834284237042557 980913038932188165 977556796318907338 96567...
result:
ok 1000000 lines
Test #10:
score: 10
Accepted
time: 955ms
memory: 204376kb
input:
1000000 1000000 4131543 2553434 22615848255 13977362906 63648 39338 26483679092 16367813826 766428 4...
output:
996943230476562837 992744165900993793 977870523681018327 973905575456964502 971181334873983918 94411...
result:
ok 1000000 lines
Extra Test:
score: 0
Extra Test Passed