ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#198935 | #3463. 最大区间 | JuRuoError_YBW | 100 | 6507ms | 33480kb | C++ | 851b | 2023-12-03 10:36:18 | 2023-12-03 12:13:35 |
answer
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define int long long
int n,k;
const int MAXN=1e6+5;
std::priority_queue<std::pair<int,std::pair<int,int> > > q;
int a[MAXN];
int gcd(int a,int b){
if(b==0)return a;
return gcd(b,(a%b));
}
signed main(){
std::cin>>n>>k;
for(int i=1;i<=n;i++)std::cin>>a[i];
for(int i=1;i<=n;i++)q.push(std::make_pair(a[i],std::make_pair(i,i)));
for(int i=1;i<=k;i++){
std::pair<int,std::pair<int,int> > tp=q.top();
q.pop();
if(tp.second.second!=n){
q.push(std::make_pair(gcd(tp.first,a[tp.second.second+1]),std::make_pair(tp.second.first,tp.second.second+1)));
}
std::cout<<tp.first<<'\n';
}
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 73ms
memory: 1296kb
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: 138ms
memory: 1300kb
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: 103ms
memory: 1296kb
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: 328ms
memory: 4972kb
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: 547ms
memory: 4972kb
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: 361ms
memory: 4968kb
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: 1552ms
memory: 33476kb
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: 1216ms
memory: 33480kb
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: 1136ms
memory: 33480kb
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: 1053ms
memory: 33480kb
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