QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#277165#4274. $2x + 2$PetroTarnavskyi#AC ✓11ms8332kbPython3375b2023-12-06 15:58:122023-12-06 15:58:14

Judging History

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

  • [2023-12-06 15:58:14]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:8332kb
  • [2023-12-06 15:58:12]
  • 提交

answer

n = int(input())

ans = 0

if n >= 2:
	k = 0	
	x = 2
	while x <= n:
		x = 2 * x + 2
		k += 1
	ans += (k + 1) // 2



n += 2

cnts = []

while n > 0:
	#[3, n] - odd
	cnt = (n + 1) // 2 - 1
	cnts.append(cnt)
		
	n = n // 2

cnts.append(0)

for k in range(len(cnts) - 1):
	cnt = cnts[k] - cnts[k + 1]
	ans += ((k + 2) // 2) * cnt
	
	
print(ans)

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 8184kb

input:

4

output:

3

result:

ok answer is '3'

Test #2:

score: 0
Accepted
time: 10ms
memory: 8184kb

input:

10000000000

output:

6666666667

result:

ok answer is '6666666667'

Test #3:

score: 0
Accepted
time: 6ms
memory: 8184kb

input:

11537

output:

7692

result:

ok answer is '7692'

Test #4:

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

input:

41309

output:

27540

result:

ok answer is '27540'

Test #5:

score: 0
Accepted
time: 10ms
memory: 8332kb

input:

8191927142339937565554845978095081242540169480073285738552305926582959325059543812213073905385467089

output:

5461284761559958377036563985396720828360112986715523825701537284388639550039695874808715936923644727

result:

ok answer is '546128476155995837703656398539...9550039695874808715936923644727'

Test #6:

score: 0
Accepted
time: 10ms
memory: 8204kb

input:

3442352750904517878505619138601923704219437640757539618101640600496556715434957688100692603387053285

output:

2294901833936345252337079425734615802812958427171693078734427066997704476956638458733795068924702192

result:

ok answer is '229490183393634525233707942573...4476956638458733795068924702192'

Test #7:

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

input:

1613323280652897219227411721866100145041476611268669226074320085219149805106782606494134047806758188

output:

1075548853768598146151607814577400096694317740845779484049546723479433203404521737662756031871172125

result:

ok answer is '107554885376859814615160781457...3203404521737662756031871172125'

Test #8:

score: 0
Accepted
time: 10ms
memory: 8208kb

input:

5315968240892751432719450950079352483724763602617515777985835699795112297723617975471814602589260139

output:

3543978827261834288479633966719568322483175735078343851990557133196741531815745316981209735059506756

result:

ok answer is '354397882726183428847963396671...1531815745316981209735059506756'

Test #9:

score: 0
Accepted
time: 10ms
memory: 8208kb

input:

4254525315983167363680527261349030702801865895012808546689914191512673794223422499077682440208603002

output:

2836350210655444909120351507566020468534577263341872364459942794341782529482281666051788293472401998

result:

ok answer is '283635021065544490912035150756...2529482281666051788293472401998'

Test #10:

score: 0
Accepted
time: 10ms
memory: 8272kb

input:

4232021319223122906781785255488524502328502739912063884613559438143045702320487112522484309917751092

output:

2821347546148748604521190170325683001552335159941375923075706292095363801546991408348322873278500728

result:

ok answer is '282134754614874860452119017032...3801546991408348322873278500728'

Test #11:

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

input:

1795624774898285292090286902750186163949672827604714746430754757406422760905150536380671234812971701

output:

1197083183265523528060191268500124109299781885069809830953836504937615173936767024253780823208647800

result:

ok answer is '119708318326552352806019126850...5173936767024253780823208647800'

Test #12:

score: 0
Accepted
time: 9ms
memory: 8208kb

input:

4822717262051522274281630372660419682967327262088834250036223458028953055139175905469830602157603781

output:

3215144841367681516187753581773613121978218174725889500024148972019302036759450603646553734771735852

result:

ok answer is '321514484136768151618775358177...2036759450603646553734771735852'

Test #13:

score: 0
Accepted
time: 10ms
memory: 8276kb

input:

2420522157427712177063212710553899155280648241917240982792673534179482218292455213946314991881868032

output:

1613681438285141451375475140369266103520432161278160655195115689452988145528303475964209994587912020

result:

ok answer is '161368143828514145137547514036...8145528303475964209994587912020'

Test #14:

score: 0
Accepted
time: 8ms
memory: 8208kb

input:

9609389761049001578964019340044768569257164534852566205215792890955388299397818366261838906610023430

output:

6406259840699334385976012893363179046171443023235044136810528593970258866265212244174559271073348955

result:

ok answer is '640625984069933438597601289336...8866265212244174559271073348955'

Test #15:

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

input:

7378100518154352784087117925119913114198069908998635745840877661112203325434672312431175562249252615

output:

4918733678769568522724745283413275409465379939332423830560585107408135550289781541620783708166168410

result:

ok answer is '491873367876956852272474528341...5550289781541620783708166168410'

Test #16:

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

input:

4314257129848969215611268956312124232769562015258259969302294181121144270721780102652371986908117553

output:

2876171419899312810407512637541416155179708010172173312868196120747429513814520068434914657938745033

result:

ok answer is '287617141989931281040751263754...9513814520068434914657938745033'

Test #17:

score: 0
Accepted
time: 10ms
memory: 8228kb

input:

7442513133020754007748287749235820140836485766563082482200516186848122640921515715527998921755861588

output:

4961675422013836005165525166157213427224323844375388321467010791232081760614343810351999281170574386

result:

ok answer is '496167542201383600516552516615...1760614343810351999281170574386'

Test #18:

score: 0
Accepted
time: 10ms
memory: 8208kb

input:

3461484012412528765843169791809202936903341569347941193333818142278082472445171817580403125597600451

output:

2307656008275019177228779861206135291268894379565294128889212094852054981630114545053602083731733632

result:

ok answer is '230765600827501917722877986120...4981630114545053602083731733632'

Test #19:

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

input:

1163272062750598620393469988307282589338426479894049959298993638249005296627594351977914826030081102

output:

775514708500399080262313325538188392892284319929366639532662425499336864418396234651943217353387402

result:

ok answer is '775514708500399080262313325538...6864418396234651943217353387402'

Test #20:

score: 0
Accepted
time: 10ms
memory: 8152kb

input:

4068560037015934876188912039122335004243864029335249206370283031741163876305460454503531769248201260

output:

2712373358010623250792608026081556669495909352890166137580188687827442584203640303002354512832134172

result:

ok answer is '271237335801062325079260802608...2584203640303002354512832134172'

Test #21:

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

input:

5565005101377395755496808721969606048354933767768901576729742263052044309300279715138209309197954425

output:

3710003400918263836997872481313070698903289178512601051153161508701362872866853143425472872798636284

result:

ok answer is '371000340091826383699787248131...2872866853143425472872798636284'

Test #22:

score: 0
Accepted
time: 8ms
memory: 8196kb

input:

5955281427312151598060753022957546231632661803019555928462527228479176277952673308710392524455774190

output:

3970187618208101065373835348638364154421774535346370618975018152319450851968448872473595016303849455

result:

ok answer is '397018761820810106537383534863...0851968448872473595016303849455'

Test #23:

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

input:

5999199660995226367587541425139665809699306237416367491756562600743005331872297761736053889864270206

output:

3999466440663484245058360950093110539799537491610911661171041733828670221248198507824035926576180135

result:

ok answer is '399946644066348424505836095009...0221248198507824035926576180135'

Test #24:

score: 0
Accepted
time: 10ms
memory: 8212kb

input:

2155514273756447121758927869937665552173017137262740529395979905843768743654327408778539354112687532

output:

1437009515837631414505951913291777034782011424841827019597319937229179162436218272519026236075125022

result:

ok answer is '143700951583763141450595191329...9162436218272519026236075125022'

Test #25:

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

input:

7588366615490051405430942621119859163585478194391436228387468801445509515856890540219070127651363167

output:

5058911076993367603620628414079906109056985462927624152258312534297006343904593693479380085100908777

result:

ok answer is '505891107699336760362062841407...6343904593693479380085100908777'

Test #26:

score: 0
Accepted
time: 10ms
memory: 8144kb

input:

3069119817864664964195356068892415035426862018367420612508577861775349962709346348512881925327625430

output:

2046079878576443309463570712594943356951241345578280408339051907850233308472897565675254616885083623

result:

ok answer is '204607987857644330946357071259...3308472897565675254616885083623'

Test #27:

score: 0
Accepted
time: 10ms
memory: 8272kb

input:

6088609027910777715746727861553568363088355582707685378247148205358342717518996505870051122255545321

output:

4059072685273851810497818574369045575392237055138456918831432136905561811679331003913367414837030215

result:

ok answer is '405907268527385181049781857436...1811679331003913367414837030215'

Test #28:

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

input:

7752395844202176560354506129946224949547707723163853784421446345689791536208995591077776340757462505

output:

5168263896134784373569670753297483299698471815442569189614297563793194357472663727385184227171641667

result:

ok answer is '516826389613478437356967075329...4357472663727385184227171641667'