C语言练习题.docx

上传人:b****2 文档编号:1991288 上传时间:2023-05-02 格式:DOCX 页数:10 大小:18.83KB
下载 相关 举报
C语言练习题.docx_第1页
第1页 / 共10页
C语言练习题.docx_第2页
第2页 / 共10页
C语言练习题.docx_第3页
第3页 / 共10页
C语言练习题.docx_第4页
第4页 / 共10页
C语言练习题.docx_第5页
第5页 / 共10页
C语言练习题.docx_第6页
第6页 / 共10页
C语言练习题.docx_第7页
第7页 / 共10页
C语言练习题.docx_第8页
第8页 / 共10页
C语言练习题.docx_第9页
第9页 / 共10页
C语言练习题.docx_第10页
第10页 / 共10页
亲,该文档总共10页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

C语言练习题.docx

《C语言练习题.docx》由会员分享,可在线阅读,更多相关《C语言练习题.docx(10页珍藏版)》请在冰点文库上搜索。

C语言练习题.docx

C语言练习题

ProblemA:

boyandgril

TimeLimit:

 1Sec  MemoryLimit:

 128MB

Submit:

 7  Solved:

 3

[Submit][Status][WebBoard]

Description

Duringthebreaktheschoolchildren,boysandgirls,formedaqueueof n peopleinthecanteen.Initiallythechildrenstoodintheordertheyenteredthecanteen.However,afterawhiletheboysstartedfeelingawkwardforstandinginfrontofthegirlsinthequeueandtheystartedlettingthegirlsmoveforwardeachsecond.

Let'sdescribetheprocessmoreprecisely.Let'ssaythatthepositionsinthequeuearesequentiallynumberedbyintegersfrom 1 to n,atthatthepersoninthepositionnumber 1 isservedfirst.Then,ifattime x aboystandsonthe i-thpositionandagirlstandsonthe(i + 1)-thposition,thenattime x + 1 the i-thpositionwillhaveagirlandthe (i + 1)-thpositionwillhaveaboy.Thetimeisgiveninseconds.

You'vegottheinitialpositionofthechildren,attheinitialmomentoftime.Determinethewaythequeueisgoingtolookafter t seconds.

Input

Thefirstlinecontainstwointegers n and t (1 ≤ n, t ≤ 50),whichrepresentthenumberofchildreninthequeueandthetimeafterwhichthequeuewilltransformintothearrangementyouneedtofind.

Thenextlinecontainsstring s,whichrepresentstheschoolchildren'sinitialarrangement.Ifthe i-thpositioninthequeuecontainsaboy,thenthe i-thcharacterofstring s equals"B",otherwisethe i-thcharacterequals"G".

Output

Printstring a,whichdescribesthearrangementafter t seconds.Ifthe i-thpositionhasaboyaftertheneededtime,thenthe i-thcharacter a mustequal"B",otherwiseitmustequal"G".

SampleInput

51

BGGBG

SampleOutput

GBGGB

ProblemB:

Word

TimeLimit:

 1Sec  MemoryLimit:

 128MB

Submit:

 27  Solved:

 7

[Submit][Status][WebBoard]

Description

VasyaisveryupsetthatmanypeopleontheNetmixuppercaseandlowercaselettersinoneword.That'swhyhedecidedtoinventanextensionforhisfavoritebrowserthatwouldchangetheletters'registerineverywordsothatiteitheronlyconsistedoflowercaselettersor,viceversa,onlyofuppercaseones.Atthataslittleaspossiblelettersshouldbechangedintheword.Forexample,thewordHoUsemustbereplacedwithhouse,andthewordViP¡ªwithVIP.Ifawordcontainsanequalnumberofuppercaseandlowercaseletters,youshouldreplacealltheletterswithlowercaseones.Forexample,maTRIxshouldbereplacedbymatrix.Yourtaskistousethegivenmethodononegivenword.

Input

Thefirstlinecontainsawords¡ªitconsistsofuppercaseandlowercaseLatinlettersandpossessesthelengthfrom1to100. 

Output

Printthecorrectedwords.Ifthegivenwordshasstrictlymoreuppercaseletters,makethewordwrittenintheuppercaseregister,otherwise-inthelowercaseone.

SampleInput

HoUse

SampleOutput

house

ProblemC:

Team

TimeLimit:

 1Sec  MemoryLimit:

 128MB

Submit:

 3  Solved:

 3

[Submit][Status][WebBoard]

Description

OnedaythreebestfriendsPetya,VasyaandTonyadecidedtoformateamandtakepartinprogrammingcontests.Participantsareusuallyofferedseveralproblemsduringprogrammingcontests.Longbeforethestartthefriendsdecidedthattheywillimplementaproblemifatleasttwoofthemaresureaboutthesolution.Otherwise,thefriendswon'twritetheproblem'ssolution.

Thiscontestoffers n problemstotheparticipants.Foreachproblemweknow,whichfriendissureaboutthesolution.Helpthefriendsfindthenumberofproblemsforwhichtheywillwriteasolution.

Input

Thefirstinputlinecontainsasingleinteger n (1 ≤ n ≤ 1000)—thenumberofproblemsinthecontest.Then n linescontainthreeintegerseach,eachintegeriseither 0 or 1.Ifthefirstnumberinthelineequals 1,thenPetyaissureabouttheproblem'ssolution,otherwiseheisn'tsure.ThesecondnumbershowsVasya'sviewonthesolution,thethirdnumbershowsTonya'sview.Thenumbersonthelinesareseparatedbyspaces.

Output

Printasingleinteger—thenumberofproblemsthefriendswillimplementonthecontest.

SampleInput

3

110

111

100

SampleOutput

2

ProblemD:

神、上帝以及老天爷

TimeLimit:

 1Sec  MemoryLimit:

 128MB

Submit:

 27  Solved:

 8

[Submit][Status][WebBoard]

Description

HDU2006'10ACMcontest的颁奖晚会隆重开始了!

 

为了活跃气氛,组织者举行了一个别开生面、奖品丰厚的抽奖活动,这个活动的具体要求是这样的:

 

首先,所有参加晚会的人员都将一张写有自己名字的字条放入抽奖箱中; 

然后,待所有字条加入完毕,每人从箱中取一个字条; 

最后,如果取得的字条上写的就是自己的名字,那么“恭喜你,中奖了!

” 

大家可以想象一下当时的气氛之热烈,毕竟中奖者的奖品是大家梦寐以求的Twins签名照呀!

不过,正如所有试图设计的喜剧往往以悲剧结尾,这次抽奖活动最后竟然没有一个人中奖!

 

我的神、上帝以及老天爷呀,怎么会这样呢?

 

不过,先不要激动,现在问题来了,你能计算一下发生这种情况的概率吗?

 

不会算?

难道你也想以悲剧结尾?

 

Input

输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每行包含一个整数n(1

Output

对于每个测试实例,请输出发生这种情况的百分比,每个实例的输出占一行, 结果保留两位小数(四舍五入),具体格式请参照sampleoutput。

 

SampleInput

1

2

SampleOutput

50.00%

HINT

ProblemE:

前m大的数

TimeLimit:

 1Sec  MemoryLimit:

 128MB

Submit:

 16  Solved:

 9

[Submit][Status][WebBoard]

Description

还记得Gardon给小希布置的那个作业么?

(上次比赛的1005)其实小希已经找回了原来的那张数表,现在她想确认一下她的答案是否正确,但是整个的答案是很庞大的表,小希只想让你把答案中最大的M个数告诉她就可以了。

 

给定一个包含N(N<=3000)个正整数的序列,每个数不超过5000,对它们两两相加得到的N*(N-1)/2个和,求出其中前M大的数(M<=N*(N-1)/2)并按从大到小的顺序排列。

Input

输入可能包含多组数据,其中每组数据包括两行:

 

第一行两个数N和M, 

第二行N个数,表示该序列。

 

Output

对于输入的每组数据,输出M个数,表示结果。

输出应当按照从大到小的顺序排列。

SampleInput

44

1234

45

5364

SampleOutput

7655

1110998

HINT

ProblemF:

shǎ崽OrOrOrOrz

TimeLimit:

 1Sec  MemoryLimit:

 128MB

Submit:

 3  Solved:

 3

[Submit][Status][WebBoard]

Description

AcmerinHDU-ACMteamareambitious,especiallyshǎ崽,hecanspendtimeinInternetbardoingproblemsovernight.SomanygirlswanttomeetandOrzhim.ButOrzhimisnotthateasy.Youmustsolvethisproblemfirst. 

Theproblemis:

 

Giveyouasequenceofdistinctintegers,choosenumbersasfollowing:

firstchoosethebiggest,thensmallest,thensecondbiggest,secondsmallestetc.Untilallthenumberswaschosen. 

Forexample,giveyou12345,youshouldoutput51423 在hdu-acm团队ACMer野心勃勃,尤其是SHǎ崽,

Input

Therearemultipletestcases,eachcasebeginswithoneintegerN(1<=N<=10000),followingNdistinctintegers.

Output

Outputasequenceofdistinctintegersdescribedabove.

SampleInput

5

12345

SampleOutput

51423

HINT

ProblemG:

A+BProblemII

TimeLimit:

 1Sec  MemoryLimit:

 33MB

Submit:

 4  Solved:

 1

[Submit][Status][WebBoard]

Description

GiventwointegersAandB,yourjobistocalculatetheSumofA+B.

Input

ThefirstlineoftheinputcontainsanintegerT(1<=T<=20)whichmeansthenumberoftestcases.ThenTlinesfollow,eachlineconsistsoftwopositiveintegers,AandB.Noticethattheintegersareverylarge.Youmayassumethelengthofeachintegerwillnotexceed2000.

Output

Foreachtestcase,youshouldoutputtwolines.Thefirstlineis"Case#:

",#meansthenumberofthetestcase.Thesecondlineistheanequation"A+B=Sum",SummeanstheresultofA+B.Notetherearesomespacesinttheequation.Outputablanklinebetweentwotestcases.

SampleInput

2

12

112233445566778899998877665544332211

SampleOutput

Case1:

1+2=3

Case2:

112233445566778899+998877665544332211=111111*********1110

HINT

ProblemH:

Eddy'sresearchI

TimeLimit:

 1Sec  MemoryLimit:

 33MB

Submit:

 3  Solved:

 2

[Submit][Status][WebBoard]

Description

Eddy'sinterestisveryextensive,recentlyheisinterestedinprimenumber.Eddydiscovertheallnumberownedcanbedividedintothemultiplyofprimenumber,buthecan'twriteprogram,soEddyhastoaskintelligentyoutohelphim,heasksyoutowriteaprogramwhichcandothenumbertodividedintothemultiplyofprimenumberfactor.

Input

Theinputwillcontainanumber1

Output

Youhavetoprintalineintheoutputforeachentrywiththeanswertothepreviousquestion.

SampleInput

11

9412

SampleOutput

11

2*2*13*181

ProblemI:

斐波那契数的整除

TimeLimit:

 1Sec  MemoryLimit:

 128MB

Submit:

 1  Solved:

 0

[Submit][Status][WebBoard]

Description

已知斐波那契数的定义:

f

(1)=1,f

(2)=1,对于n>=3,f(n)=f(n-1)+f(n-2).它的前几项可以表示为1,1,2,3,5,8,13,21,34...,问f(n)的值是否能被3和4整除.

Input

输入数据有若干组,每组数据包含一个整数n,(1

Output

对于每组数据n,如若f(n)能被12整除则输出“YES

”,否则如若能被3整除则输出“3”; 能被4整除则输出“4”,若都不满足否则输出“NO”.

SampleInput

4

6

7

SampleOutput

3

4

NO

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2