急切求问ACM的两道题!
1>ProblemDescription
Theleastcommonmultiple(LCM)ofasetofpositiveintegersisthesmallestpositiveintegerwhichisdivisiblebyallthenumbersintheset.Forexample,theLCMof5,7and15is105.
Input
Inputwillconsistofmultipleprobleminstances.Thefirstlineoftheinputwillcontainasingleintegerindicatingthenumberofprobleminstances.Eachinstancewillconsistofasinglelineoftheformmn1n2n3...nmwheremisthenumberofintegersinthesetandn1...nmaretheintegers.Allintegerswillbepositiveandliewithintherangeofa32-bitinteger.
Output
Foreachprobleminstance,outputasinglelinecontainingthecorrespondingLCM.Allresultswilllieintherangeofa32-bitinteger.
SampleInput
2
35715
641029693612877921
SampleOutput
105
10296
我的答案总是显示wronganswer!求教:
#include
intgcd(intda,intxiao)
{inttemp;
while(xiao!=0)
{
temp=da%xiao;
da=xiao;
xiao=temp;
}
return(da);
}
voidmain()
{
intx,m,n,n1,t,i,j;
scanf("%d",&n);
for(i=0;i
Elevator
ProblemDescription
Thehighestbuildinginourcityhasonlyoneelevator.ArequestlistismadeupwithNpositivenumbers.Thenumbersdenoteatwhichfloorstheelevatorwillstop,inspecifiedorder.Itcosts6secondstomovetheelevatoruponefloor,and4secondstomovedownonefloor.Theelevatorwillstayfor5secondsateachstop.
Foragivenrequestlist,youaretocomputethetotaltimespenttofulfilltherequestsonthelist.Theelevatorisonthe0thflooratthebeginninganddoesnothavetoreturntothegroundfloorwhentherequestsarefulfilled.
Input
Therearemultipletestcases.EachcasecontainsapositiveintegerN,followedbyNpositivenumbers.Allthenumbersintheinputarelessthan100.AtestcasewithN=0denotestheendofinput.Thistestcaseisnottobeprocessed.
Output
Printthetotaltimeonasinglelineforeachtestcase.
SampleInput
12