字典翻译 问答 小学 英语 急切求问ACM的两道题!1>ProblemDescriptionTheleastcommonmultiple(LCM)ofasetofpositiveintegersisthesmallestpositiveintegerwhichisdivisiblebyallthenumbersintheset.Forexample,theLCMof5,7and15is105.InputInputwi
问题标题:
急切求问ACM的两道题!1>ProblemDescriptionTheleastcommonmultiple(LCM)ofasetofpositiveintegersisthesmallestpositiveintegerwhichisdivisiblebyallthenumbersintheset.Forexample,theLCMof5,7and15is105.InputInputwi
问题描述:

急切求问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

康海贵回答:
  1.虽然题目说所有结果都在32bit(unsignedint)以内,但是中间结果x*s可能会超出这个范围,用unsignedint都表示不了,所以得用longlong或者用高精度.   2.while(scanf("%d",&n),n)这个是本来就有的语法错误还是你不小心弄错的.但题目其实表述得不是很完整,如果N的取值在10的6次方以内,那么最有可能错的是电梯有可能连续在同一层停多次(x==a)!否则就是得用longlong来存结果.   最好给出这些题的出处,好让回答者去试试呀~
点击显示
英语推荐
热门英语推荐
  • 语文
  • 数学
  • 英语
  • 科学
  • 作文