QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#338035#5050. ValueKevin5307AC ✓72ms5288kbC++23845b2024-02-25 17:06:512024-02-25 17:06:51

Judging History

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

  • [2024-02-25 17:06:51]
  • 评测
  • 测评结果:AC
  • 用时:72ms
  • 内存:5288kb
  • [2024-02-25 17:06:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a[100100],b[100100];
bool flag[100100];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	ll ans=a[1];
	for(int i=2;i<=n;i++)
		if(!flag[i])
		{
			if(i*i>n)
			{
				ans+=a[i];
				continue;
			}
			vector<pair<int,int>> vec;
			for(ll j=i,c=1;j<=n;j*=i,c++)
			{
				vec.emplace_back(j,c);
				flag[j]=1;
			}
			ll mx=0;
			int m=vec.size();
			for(int j=0;j<(1<<m);j++)
			{
				ll tot=0;
				for(int k=0;k<m;k++)
					if(j>>k&1)
						tot+=a[vec[k].first];
				for(int k=0;k<m;k++) if(j>>k&1)
					for(int l=k+1;l<m;l++) if(j>>l&1)
						if(vec[l].second%vec[k].second==0)
							tot-=b[vec[l].first];
				mx=max(mx,tot);
			}
			ans+=mx;
		}
	cout<<ans<<endl;
	return 0;
}

详细

Test #1:

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

input:

4
1 1 1 2
1 1 1 1

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

4
1 1 1 1
1 1 1 2

output:

3

result:

ok 1 number(s): "3"

Test #3:

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

input:

1
4
10

output:

4

result:

ok 1 number(s): "4"

Test #4:

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

input:

2
6 8
2 4

output:

14

result:

ok 1 number(s): "14"

Test #5:

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

input:

5
1 6 10 5 1
7 1 5 10 9

output:

18

result:

ok 1 number(s): "18"

Test #6:

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

input:

10
2 2 8 10 2 10 8 10 6 5
9 2 7 4 2 2 8 3 10 10

output:

55

result:

ok 1 number(s): "55"

Test #7:

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

input:

10
8 2 28 71 6 85 90 19 75 99
58 32 12 97 22 54 95 2 22 41

output:

459

result:

ok 1 number(s): "459"

Test #8:

score: 0
Accepted
time: 1ms
memory: 3540kb

input:

10
499378161 580312139 297991977 488549686 446728905 94747359 449577305 348551824 91900269 509840562
195391767 900284766 199070364 13166132 91649641 462416747 349376583 358291497 486025165 865291797

output:

3353959962

result:

ok 1 number(s): "3353959962"

Test #9:

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

input:

100
457992034 292706810 675334392 753902137 68910383 43232856 93369738 421897111 2553628 571090809 308473918 823046294 353799547 596697775 689497551 634976771 180311057 487479264 238310828 773159036 689460373 21840389 460321400 444499701 961273652 170165163 343911050 28242743 466702096 877051765 309...

output:

42242895657

result:

ok 1 number(s): "42242895657"

Test #10:

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

input:

100
486342294 640034805 116328197 318162835 39561592 805725108 594609889 653511108 294477518 652922309 577371886 601529202 961360083 316914599 630048249 821394943 617577478 471190718 842113363 185539825 830514090 434572500 858130769 573409395 372400199 154412691 349010381 448381393 329822759 7017456...

output:

49995353551

result:

ok 1 number(s): "49995353551"

Test #11:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

1000
448894631 183123026 397536202 695859698 441207641 802550098 754562453 970029739 793685893 84998873 617823553 939902778 48522348 210952668 110891265 472327126 769948243 504528886 484642894 899868060 873491202 936738789 691583586 408761099 273650760 832514570 933444283 906602631 957885556 2390632...

output:

481253884637

result:

ok 1 number(s): "481253884637"

Test #12:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

1000
431940173 877072106 812881880 498506229 781976778 181162626 821675096 355364102 858897905 78207269 220287853 700799741 950195334 677020604 857218438 11419512 487886146 1351742 541400646 260024939 406623057 401233466 667729667 625068702 976659156 366324562 637947720 775790125 361947488 771049914...

output:

503564405157

result:

ok 1 number(s): "503564405157"

Test #13:

score: 0
Accepted
time: 7ms
memory: 3680kb

input:

10000
897180145 639024783 297814345 599347347 335699724 653902766 731457122 359537664 890880519 961735566 974069309 600480085 710274564 529416610 556671369 459228576 203765211 505991218 781364708 773174786 927669398 887443162 413959780 361539122 351822835 484024073 127009297 276696312 626246885 3275...

output:

4950387399123

result:

ok 1 number(s): "4950387399123"

Test #14:

score: 0
Accepted
time: 7ms
memory: 3952kb

input:

10000
99283948 80018588 157042338 275031260 803224680 155142917 963071119 651461554 267679314 525600830 607328025 208040621 285267196 469967308 892832645 336686486 627668154 549985240 338969689 63971608 340401509 990285235 837836769 772665669 895878875 343899212 692372139 549882383 450940796 7617906...

output:

4958574994437

result:

ok 1 number(s): "4958574994437"

Test #15:

score: 0
Accepted
time: 67ms
memory: 5280kb

input:

100000
746411323 844734199 828701336 498763883 140622415 41748996 283525015 150874283 490856305 794774154 978830637 62220090 406108977 945064992 966918653 799999763 458956649 476010818 399933489 893718613 902605235 148991441 992417782 665098944 232865262 895486864 349693949 721517627 933206717 63472...

output:

49932359912727

result:

ok 1 number(s): "49932359912727"

Test #16:

score: 0
Accepted
time: 67ms
memory: 5188kb

input:

100000
66205052 506896010 756406149 487044309 145126870 210147014 722789256 297938031 111004082 309881663 640896508 84533947 276419186 658159213 692567706 678489884 351256519 243530044 869443759 738028200 419324475 264826254 85012382 230933673 357095337 475849910 592227164 182990624 486600639 736858...

output:

50075136274277

result:

ok 1 number(s): "50075136274277"

Test #17:

score: 0
Accepted
time: 60ms
memory: 5056kb

input:

86367
573211826 508844410 935990249 824848482 297368938 286411188 292074892 463486812 723645035 353978376 548104374 892385309 119697350 891842030 897469171 635475755 191312931 924186007 509167011 335732989 102896953 180639844 553137785 847045249 50519127 561149292 779215869 652791190 616612575 67875...

output:

43167811669332

result:

ok 1 number(s): "43167811669332"

Test #18:

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

input:

46111
511011916 93479355 598152060 47520591 580616660 145691451 870538318 757526861 575741487 974126153 917987691 114259692 142011207 762152238 610563392 510867912 364770347 816485877 276686237 954986363 947206540 547615980 668972598 794415657 321386561 390412071 504803107 895324405 373052867 672335...

output:

23049432765563

result:

ok 1 number(s): "23049432765563"

Test #19:

score: 0
Accepted
time: 4ms
memory: 3728kb

input:

5855
448812006 413273084 525155087 124968508 568897087 445163201 38936336 196791101 868029428 449049739 728062496 631101372 869357768 632462447 618624909 941549669 93517363 563561555 484396951 129529338 496548831 504526708 79774707 446818769 887221291 809609442 230390344 988114516 984268968 37095372...

output:

2927555983082

result:

ok 1 number(s): "2927555983082"

Test #20:

score: 0
Accepted
time: 28ms
memory: 4476kb

input:

41406
91644801 292875326 187316899 202416425 997369001 599410759 207334354 195863854 15093176 69197517 243170006 852975755 596704329 62581167 331719130 521974529 117231676 455861426 251916177 453815416 45891122 871502845 490576815 834380665 453056020 933839517 955977582 525615026 740709261 924347650...

output:

20697788929571

result:

ok 1 number(s): "20697788929571"

Test #21:

score: 0
Accepted
time: 47ms
memory: 4692kb

input:

68446
324412187 612669055 114319926 984897046 280616723 898882509 80765076 340160799 162156925 689345294 758277515 515041626 619018186 932891375 44813352 102399390 290689092 348161296 19435403 218292983 744976518 533446277 751635820 781751073 18890750 353036888 681564820 618405137 351925362 91793306...

output:

34221296912585

result:

ok 1 number(s): "34221296912585"

Test #22:

score: 0
Accepted
time: 39ms
memory: 4628kb

input:

60213
526506666 526219841 99950948 263035914 943108786 315899757 421376495 589215578 219900896 107553135 46017031 655415145 468022585 216000471 78224750 320360975 492125399 916746086 498535990 419683738 469431401 563699347 632555846 790679883 60368814 504906761 716642524 867573204 244520702 61520771...

output:

30049215164265

result:

ok 1 number(s): "30049215164265"

Test #23:

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

input:

33004
50703049 51318670 15191545 4949157 78980753 68819571 40994019 72723428 51474573 48078566 38898739 23182655 58743918 34642842 61744387 89141218 48053335 25960402 42521122 69927372 15170147 32943082 48342419 76588370 87894301 6940878 95356172 70495388 81142534 4031617 6565240 73930788 52519442 9...

output:

1641850476379

result:

ok 1 number(s): "1641850476379"

Test #24:

score: 0
Accepted
time: 4ms
memory: 3676kb

input:

7111
29310206 93613961 1409542 74242559 54664667 36344527 82425659 54080529 38365759 29910066 97731299 1665562 16561349 54859665 2295085 80592094 25511245 4639153 86515145 87340866 51191160 40642489 95894892 60273872 53796655 96221110 455503 95666742 94520093 33758232 30566833 77671879 42085936 3762...

output:

354974899020

result:

ok 1 number(s): "354974899020"

Test #25:

score: 0
Accepted
time: 5ms
memory: 3752kb

input:

7423
556562884 308821813 673503146 803220816 443512703 34975807 887077653 604890719 621502428 211872777 804340086 89096778 389755274 752902361 948045015 519140165 698848140 262354798 238530263 267417397 961568188 406595959 173373735 56855606 216177475 702943769 313794060 344397590 409378083 89948938...

output:

3696402011227

result:

ok 1 number(s): "3696402011227"

Test #26:

score: 0
Accepted
time: 56ms
memory: 4920kb

input:

81530
289945848 215958320 259721144 222257322 414163913 797468060 93350508 131472012 913426318 588671572 368205350 17322790 292283105 622862289 448404225 410591042 136114562 391290444 282524286 530055083 397589201 819328070 571183104 40541107 482079830 687191296 468636496 614793136 122755642 4292160...

output:

40761816676072

result:

ok 1 number(s): "40761816676072"

Test #27:

score: 0
Accepted
time: 65ms
memory: 5288kb

input:

100000
259112117 203260 503082960 210976988 101393125 705911732 235354621 531881315 618151172 606375488 724757384 583582082 810989761 718230241 13326289 565669501 133260875 908652287 554071801 606621693 344906969 476762275 993205353 934403726 586714404 431851771 426809163 279680032 41250792 87337135...

output:

50022522743407

result:

ok 1 number(s): "50022522743407"

Test #28:

score: 0
Accepted
time: 65ms
memory: 5212kb

input:

100000
6012019 42294647 59272313 271502 94135114 29146545 25796886 65617554 75753775 33803781 47819481 48399095 26777188 88114846 71661692 2255602 49744319 11543131 37672592 44687019 89943338 65056845 9085176 75926207 53546787 80664125 89313899 84818366 87609401 55701027 60493045 31978670 54779797 8...

output:

4978984811290

result:

ok 1 number(s): "4978984811290"

Test #29:

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

input:

100000
8 35 44 29 84 15 41 71 2 73 12 32 46 34 80 18 85 98 23 93 55 28 69 55 21 88 79 23 76 69 21 41 84 19 1 16 82 26 70 81 94 17 93 57 41 28 59 23 73 62 97 63 88 80 7 64 89 28 62 19 63 91 70 73 4 96 64 45 59 10 57 20 86 50 29 99 40 86 98 53 24 19 98 95 89 53 52 93 88 58 16 63 57 98 30 46 47 18 27 8...

output:

5053607

result:

ok 1 number(s): "5053607"

Test #30:

score: 0
Accepted
time: 39ms
memory: 5252kb

input:

100000
861 406 348 825 845 396 560 498 44 260 474 465 187 605 271 742 112 35 911 86 294 773 702 60 266 709 756 835 623 251 701 525 395 267 346 631 152 818 551 850 20 108 931 204 25 353 91 613 29 484 750 635 907 195 858 14 433 770 590 708 16 128 510 758 552 567 683 745 121 704 192 143 746 397 478 235...

output:

49959695

result:

ok 1 number(s): "49959695"

Test #31:

score: 0
Accepted
time: 72ms
memory: 5288kb

input:

100000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

99685000000000

result:

ok 1 number(s): "99685000000000"

Test #32:

score: 0
Accepted
time: 52ms
memory: 5276kb

input:

100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

99685

result:

ok 1 number(s): "99685"

Test #33:

score: 0
Accepted
time: 45ms
memory: 5228kb

input:

100000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

99999999999593

result:

ok 1 number(s): "99999999999593"