QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#699425#9545. Magical Setucup-team3555#AC ✓38ms16576kbC++202.2kb2024-11-02 08:55:582024-11-05 20:19:42

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 20:19:42]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:38ms
  • 内存:16576kb
  • [2024-11-05 20:19:41]
  • hack成功,自动添加数据
  • (/hack/1133)
  • [2024-11-05 15:41:10]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:37ms
  • 内存:16640kb
  • [2024-11-05 15:40:40]
  • hack成功,自动添加数据
  • (/hack/1120)
  • [2024-11-05 01:07:41]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:40ms
  • 内存:16804kb
  • [2024-11-05 01:07:31]
  • hack成功,自动添加数据
  • (/hack/1119)
  • [2024-11-02 08:55:58]
  • 评测
  • 测评结果:100
  • 用时:40ms
  • 内存:16740kb
  • [2024-11-02 08:55:58]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long 

const int N=1e6+5,M=31623;
const ll inf=1e9;
int n,m,idx=0,prm[N],cnt=0,ct[N];
bool vis[N];
gp_hash_table<int,int> mp;

namespace MCMF{
  int S,T,head[N],tot=1,cur[N];
  ll dis[N];
  bool vis[N];
  struct Edge{
  	int v,nxt;
  	ll w,c;
  }e[N<<1];
  
  void add(int u,int v,int w,int c){
  	e[++tot]={v,head[u],w,-c};head[u]=tot;
  	e[++tot]={u,head[v],0,c},head[v]=tot;
  }
  
  bool spfa(){
  	for(int i=S;i<=T;i++) dis[i]=inf,cur[i]=head[i],vis[i]=false;
  	queue<int> Q;
  	dis[S]=0,Q.push(S),vis[S]=1;
  	while(!Q.empty()){
  	  int u=Q.front();Q.pop();
	  vis[u]=0;
	  for(int i=head[u];i;i=e[i].nxt){
	  	int v=e[i].v;ll w=e[i].w,c=e[i].c;
	  	if(w&&dis[v]>dis[u]+c){
	  	  dis[v]=dis[u]+c;
		  if(!vis[v]) Q.push(v),vis[v]=1;	
		}
	  }	
	}
	return dis[T]!=inf;
  }
  
  ll dfs(int u,ll flow){
  	if(u==T||!flow) return flow;
  	ll res=flow;
  	vis[u]=1;
	for(int i=cur[u];i&&res;i=e[i].nxt){
  	  cur[u]=i;
  	  int v=e[i].v;ll w=e[i].w,c=e[i].c;
  	  if(!vis[v]&&w&&dis[v]==dis[u]+c){
  	    ll f=dfs(v,min(w,res));
		res-=f,e[i].w-=f,e[i^1].w+=f;	
	  }
	}
	return flow-res;
  }
  
  ll dinic(){
  	ll res=0,ans=0;
  	while(spfa()){
  	  ll flow=dfs(S,inf);
	  res+=flow,ans+=flow*dis[T];	
	}
	return ans;
  }
}

void init(){
  for(int i=2;i<=M;i++){
    if(!vis[i]) prm[++cnt]=i;
    for(int j=1;j<=cnt&&i*prm[j]<=M;j++){
      vis[i*prm[j]]=1;
      if(i%prm[j]==0) break;
    }
  }
}

int Count(int x){
  int res=0;
  for(int i=1;i<=cnt&&prm[i]<=x;i++) while(x%prm[i]==0) x/=prm[i],++res;
  if(x>1) ++res;
  return res;
}

void wrk(int i,int j,int nw){
  if(mp.find(j)==mp.end()) mp[j]=++idx,ct[idx]=Count(j);
  MCMF::add(i,mp[j],1,nw-ct[mp[j]]);
}

int main(){
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n;MCMF::S=0,idx=n;init();
  for(int i=1,x;i<=n;i++){
    cin>>x,MCMF::add(MCMF::S,i,1,0);
    int nw=Count(x);
    for(int j=1;j*j<=x;j++) if(x%j==0){
      wrk(i,j,nw);
      if(j*j!=x) wrk(i,x/j,nw);
    }
  }
  MCMF::T=++idx;
  for(int i=n+1;i<idx;i++) MCMF::add(i,idx,1,0);
  cout<<-MCMF::dinic();
  return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 13896kb

input:

3
2 4 6

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 2ms
memory: 9724kb

input:

6
2 3 5 6 10 12

output:

3

result:

ok single line: '3'

Test #3:

score: 0
Accepted
time: 3ms
memory: 13884kb

input:

1
1

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 0ms
memory: 10212kb

input:

1
735134400

output:

15

result:

ok single line: '15'

Test #5:

score: 0
Accepted
time: 2ms
memory: 13880kb

input:

2
1 2

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 0ms
memory: 11852kb

input:

20
41 93 206 223 284 297 339 403 474 518 521 571 637 729 734 754 837 842 945 1000

output:

37

result:

ok single line: '37'

Test #7:

score: 0
Accepted
time: 2ms
memory: 10136kb

input:

20
35922304 124138674 156896716 201255078 360247130 439329090 443603089 467049996 561750675 589197670 620970522 630712763 674436226 687175642 692397650 708613992 784328202 793365993 895628657 1000000000

output:

92

result:

ok single line: '92'

Test #8:

score: 0
Accepted
time: 2ms
memory: 9764kb

input:

40
8 51 82 93 114 165 174 187 216 224 248 325 328 330 331 336 358 368 403 410 414 463 472 520 577 613 626 667 744 749 802 844 887 903 904 910 911 959 979 1000

output:

71

result:

ok single line: '71'

Test #9:

score: 0
Accepted
time: 2ms
memory: 10016kb

input:

40
58725 66885 87908 92237 138500 140194 171682 227647 238817 311307 444556 454975 459318 465376 469292 469455 476914 513372 521171 531237 543467 566340 598915 601369 638925 654913 757870 784366 795827 796087 835627 846885 864797 876699 908007 914151 917570 989631 995272 1000000

output:

111

result:

ok single line: '111'

Test #10:

score: 0
Accepted
time: 0ms
memory: 14232kb

input:

40
99752893 101979689 107216467 130339540 137493510 138738208 162741062 180249929 186516816 187235074 358278013 384785273 400149496 411395765 421357351 437374604 455076645 505755921 523688878 530891027 573299367 596827139 637359701 639369172 657663951 777572838 796566287 825817949 831054329 84740378...

output:

128

result:

ok single line: '128'

Test #11:

score: 0
Accepted
time: 2ms
memory: 11888kb

input:

100
3 18 24 55 60 71 82 83 89 90 103 110 129 161 204 208 209 225 228 233 260 279 283 287 291 321 329 338 343 360 369 371 384 401 408 420 431 435 442 446 450 461 473 484 489 496 499 510 511 521 526 529 539 546 548 551 567 568 602 606 631 642 643 649 652 663 670 680 687 704 711 717 730 746 776 779 786...

output:

145

result:

ok single line: '145'

Test #12:

score: 0
Accepted
time: 11ms
memory: 16108kb

input:

100
19303936 22038015 24731746 28433798 33071886 34624499 46331683 49242785 57793889 85183900 99228787 121211959 121455741 121604367 122656838 142760737 161523016 188225464 210782097 222034252 224345010 230364653 243777644 261299274 269988981 285750541 287013597 287075370 320694094 343378671 4017154...

output:

325

result:

ok single line: '325'

Test #13:

score: 0
Accepted
time: 0ms
memory: 9956kb

input:

300
5 7 11 17 18 20 21 29 30 34 36 45 46 47 49 52 53 57 61 62 63 67 84 86 88 91 93 97 100 105 115 118 129 135 140 143 145 147 151 162 174 175 176 180 186 199 204 205 210 213 215 217 219 222 223 229 231 235 236 237 243 245 247 250 265 266 268 269 270 277 280 284 286 288 289 290 294 297 301 303 305 31...

output:

280

result:

ok single line: '280'

Test #14:

score: 0
Accepted
time: 3ms
memory: 10452kb

input:

300
2524 7089 7240 8917 13393 18978 20723 22083 22870 23108 24917 27032 27932 29466 33702 35729 37231 40509 42105 46630 50133 52114 60192 61431 63589 66831 73669 74133 75079 75085 76698 76956 82900 84352 89376 89725 91582 93228 95721 96337 104620 105974 107004 108495 112126 114539 124273 125013 1296...

output:

737

result:

ok single line: '737'

Test #15:

score: 0
Accepted
time: 22ms
memory: 10636kb

input:

300
3214472 5686438 7498489 8153449 10901408 11904555 12249901 15868342 17591998 21550384 26486927 28187351 43738496 56878914 63354478 66909905 68799118 71022752 73330523 75751053 76827761 80363922 87657073 89729947 93175069 93923577 94884550 96398806 97120985 100276275 105016979 124505538 124794641...

output:

934

result:

ok single line: '934'

Test #16:

score: 0
Accepted
time: 21ms
memory: 10200kb

input:

300
31501984 444810752 2391008 409578496 191968256 16137824 893446144 81166336 318712 578573312 25060352 26704736 31794944 230875136 393853952 649428992 525026 236914 12241408 3695092 3468044 13582336 274677248 1661432 240643072 59896064 723586 2763032 175171072 6873952 45877376 37155584 28561696 83...

output:

1852

result:

ok single line: '1852'

Test #17:

score: 0
Accepted
time: 15ms
memory: 14096kb

input:

300
46259991 210931047 8715771 4331799 596401461 1601361 5295861 162853 65064789 4051143 24666363 31097277 213591897 60686739 3584907 136454949 1249389 110477 11326311 21542841 345567141 722750283 465436611 50825961 348851 111537 511888491 405781 6671097 8024823 513977 7006761 135043 193247 6412347 ...

output:

1001

result:

ok single line: '1001'

Test #18:

score: 0
Accepted
time: 14ms
memory: 10116kb

input:

300
8848089 734303 36493 145146087 575693 391187961 23281371 544699 56660067 254099511 726500259 100203237 643243 609959403 883691 891101 436467609 908723 226521441 65119 21791079 721381 655181 259934427 323537 140304069 24074847 2096307 632483 941489 301246857 24595839 10180377 15189957 8641431 532...

output:

907

result:

ok single line: '907'

Test #19:

score: 0
Accepted
time: 15ms
memory: 12312kb

input:

300
542728512 8613144 893383 209449 618349 796259 61329384 44080488 328411 797473 318811 603443 245071 797003712 21188808 19061928 108709 87221 29605824 63455544 336581568 16519176 344587 234713 27380952 10077768 66992832 32446152 535351 561650112 464143 142433 589471 343081 967391 68631912 30601152...

output:

936

result:

ok single line: '936'

Test #20:

score: 0
Accepted
time: 3ms
memory: 13944kb

input:

300
372121 605257 194827 668579 624271 614723710 4943 36709 696989 902089 541721 320591 273719 166843 637603 434867 631733 906497 985057 927403 400151 446863 229459 665069 223841 853637 839491 523519 330199 466909 955819 159293 800143 427967 249541 898129 262957 798751 603487 974863 551981 424331 91...

output:

19

result:

ok single line: '19'

Test #21:

score: 0
Accepted
time: 38ms
memory: 14560kb

input:

300
930746368 796788736 660118528 882722816 848647168 885671936 857288704 740512768 585419776 877677568 628363264 659588096 565243904 537580544 669672448 610358272 729438208 590833664 670263296 643825664 666223616 991474688 707989504 866444288 639437824 514164736 649398272 971568128 874479616 566969...

output:

3330

result:

ok single line: '3330'

Test #22:

score: 0
Accepted
time: 38ms
memory: 10616kb

input:

300
575802368 252647168 252470528 884948992 250014976 784027648 512828416 904784896 590728192 541355008 873479168 278797312 758526976 349290496 739828736 791538688 262684672 370035712 931459072 877106176 466038784 601293824 555470848 571485184 321614848 555600896 654797824 385567744 252465152 675367...

output:

3237

result:

ok single line: '3237'

Test #23:

score: 0
Accepted
time: 31ms
memory: 14488kb

input:

300
395506688 555744256 315894784 612666368 768019456 290729984 762523648 861114368 629513216 254249984 619123712 254276864 899940352 731051008 794561536 347558912 533086208 791953408 670456832 978243584 764240896 299908096 571584512 707777536 845627392 663571456 720729088 884150272 630811648 710935...

output:

3211

result:

ok single line: '3211'

Test #24:

score: 0
Accepted
time: 24ms
memory: 16576kb

input:

300
438899553 605594151 583731441 191392389 709244829 532504611 287247141 555396669 354043953 279105669 906605541 307924497 364927923 509329701 727697277 667817217 309758661 237960909 532621251 635147811 180251811 691062111 338994477 673612767 383651559 550327203 216391257 169749837 517616973 367547...

output:

1935

result:

ok single line: '1935'

Test #25:

score: 0
Accepted
time: 23ms
memory: 16052kb

input:

300
671523453 101843487 385510509 116034201 567597213 124476021 431113833 441856377 308615589 372213549 538373061 415345563 616459167 658580787 673210359 76806711 222023511 275561271 178401609 236852829 646272351 185010723 60249663 683534457 55379943 159663393 896383503 43618257 704488833 613881423 ...

output:

1879

result:

ok single line: '1879'

Test #26:

score: 0
Accepted
time: 38ms
memory: 10596kb

input:

300
43641432 71556552 67287384 56477448 66311928 16889112 70637544 40184136 35950248 16125768 22916808 58875912 45354744 577191744 24906456 62656488 577222848 22391784 64821096 30509928 92809152 24118056 31178376 39757896 223601472 54635544 70736616 58162248 38353464 37196424 42600456 41052456 54082...

output:

1811

result:

ok single line: '1811'

Test #27:

score: 0
Accepted
time: 32ms
memory: 10680kb

input:

300
277259264 320155659 458044551 902597000 598091283 992564224 533622784 648910000 411089375 351622144 666464193 152057731 216676873 696968192 628596875 308619776 614352896 336146432 169181696 480272896 373421056 848417000 384694784 739859375 141679000 316808496 337061169 773146624 404253125 342449...

output:

2134

result:

ok single line: '2134'

Test #28:

score: 0
Accepted
time: 34ms
memory: 16088kb

input:

300
557993367 191862016 506817648 560464272 446374912 717967000 319967577 178961132 177801181 164050596 97718528 187449892 234008576 178267275 799432875 220761031 305234375 220090625 332943125 166466800 72840068 218762325 135690496 107470987 273115125 280633339 83491236 568646973 207918675 294191028...

output:

1771

result:

ok single line: '1771'

Test #29:

score: 0
Accepted
time: 35ms
memory: 14488kb

input:

300
201869100 244176444 172933000 355100152 196011875 433165248 175497916 202885376 216104356 767713576 142971523 118099152 166597156 316609884 91056113 613664387 210882744 178427277 350846800 226195600 480896936 161246016 205801984 303599164 172633536 953095949 853955100 214344653 221401575 5700663...

output:

1539

result:

ok single line: '1539'

Test #30:

score: 0
Accepted
time: 24ms
memory: 16296kb

input:

300
17985046 26341272 22672752 45480550 37125205 64059385 374571308 33371555 28004150 216460224 44436598 417208887 102303643 957005672 28632137 44065850 192262708 657055700 356920532 14377222 220534893 62233992 39381815 726085675 18171226 24484781 33935965 768722688 348396875 144186300 33402374 2473...

output:

1129

result:

ok single line: '1129'

Test #31:

score: 0
Accepted
time: 34ms
memory: 16288kb

input:

300
254501888 938632192 599680503 385706875 616838125 744671875 577448125 880449536 721298432 870984704 907015625 385033743 863836569 240055625 390359817 939594752 230783125 687674368 396855625 603216875 836492288 592368633 553072617 919271875 828172288 659226681 318393344 542150656 463474688 300713...

output:

2300

result:

ok single line: '2300'

Test #32:

score: 0
Accepted
time: 33ms
memory: 10324kb

input:

300
442017648 904671875 227614457 259077847 196722216 648584375 991767321 825736192 479900672 333287269 551404544 708057088 520462989 932928273 382104621 659677151 514430352 828982512 897327104 365854375 671392768 847689857 367692291 500239071 367320501 471044987 476766729 399560704 362729259 542257...

output:

2134

result:

ok single line: '2134'

Test #33:

score: 0
Accepted
time: 11ms
memory: 14196kb

input:

300
32358028 993197 859609 438829694 108718802 818260776 416653966 487934859 22501 68321067 479029 210173 827699 902834787 269054602 223645834 150679586 321411621 833420392 578988893 685176434 294341 729672774 337231029 492436018 806444014 363102106 395653802 961093656 798489674 414653 533138155 761...

output:

579

result:

ok single line: '579'

Test #34:

score: 0
Accepted
time: 19ms
memory: 16028kb

input:

300
1916756 5789912 379330815 555411510 680164727 534652944 86278269 3364964 696642 9041 468288841 476370596 525971428 609120739 3633732 231788223 548744536 975265 120957920 819743387 18775552 836214532 130144536 21682900 34984900 541901270 137049344 601628304 2002491 6759290 360782013 79224100 3094...

output:

987

result:

ok single line: '987'

Test #35:

score: 0
Accepted
time: 17ms
memory: 10520kb

input:

300
880539653 99924050 804355221 933110863 3965276 28429696 960962543 114541279 912201252 396539292 809838305 77127457 5197970 874826146 256506762 118719969 10836994 66743552 68297344 4724792 264665946 35452904 533811538 6268 821232584 949569064 992312889 818362739 3458725 21665799 161326889 1675724...

output:

988

result:

ok single line: '988'

Test #36:

score: 0
Accepted
time: 20ms
memory: 16344kb

input:

300
490462208 639950199 26896293 7692179 4932190 1853276 172540133 616618748 402274593 866740330 4892101 826259571 8296545 357960968 980719892 140578173 7968732 16345073 665237152 704949472 26566987 997229046 47335021 5349838 534331266 748516841 35931161 194238208 40321193 11387286 851494431 1177979...

output:

1010

result:

ok single line: '1010'

Test #37:

score: 0
Accepted
time: 16ms
memory: 16088kb

input:

300
539502820 663171968 5316146 21234800 39494117 98906149 993108631 289795795 882566953 317873358 714913520 403330826 969598585 532266830 4798325 84427853 639238 1880377 6298905 480146479 3704817 982266449 25780681 3886918 966090011 29693375 868148561 274934875 519552098 913291663 18154075 15038065...

output:

742

result:

ok single line: '742'

Test #38:

score: 0
Accepted
time: 21ms
memory: 16300kb

input:

300
67439488 14059542 890155091 93224375 5073273 215932753 370661058 132311591 481532 1735675 1434627 625878567 768295235 54503872 173618847 933402014 38765696 560152 273098876 586803612 330794 1367109 8220447 12952525 77847296 59390336 59221297 277245736 71910016 65322531 7687899 3776504 133894 427...

output:

1001

result:

ok single line: '1001'

Test #39:

score: 0
Accepted
time: 18ms
memory: 10316kb

input:

300
2020353 2170317 30637668 5797648 486730819 5955649 407861248 77905933 79804948 74653665 249246735 16517125 20414673 142271992 640119741 3050312 779065875 934012135 3656863 868408608 118483712 572050119 332961506 145223361 8395137 4105096 261729973 152276328 613110438 77314304 446332802 465168960...

output:

1029

result:

ok single line: '1029'

Test #40:

score: 0
Accepted
time: 15ms
memory: 12272kb

input:

300
206369 313583 419155923 219677 26164141 6563 885076705 807770201 177589 169399 930818447 912983918 282493 70121 264791 123289 128449643 910660854 36257916 241132887 264289 94111 305159090 284201 208223 58400182 223253 42829 284831 456109562 289193 42473 7673 304481 286063 63955689 16381 258253 6...

output:

420

result:

ok single line: '420'

Extra Test:

score: 0
Extra Test Passed