DescriptionFarmerJohn'sN(1<=N<=50,000)cowsarestandinginaverystraightrowandmooing.Eachcowhasauniqueheighthintherange1..2,000,000,000nanometers(FJreallyisasticklerforprecision).Eachcowmoosatsomevolumevintherange1..10,000.This"moo"travelsacrosstherowofcowsinbothdirections(exceptfortheendcows,obviously).Curiously,itisheardonlybytheclosestcowineachdirectionwhoseheightisstrictlylargerth...
DescriptionStanhasnsticksofvariouslength.Hethrowsthemoneatatimeonthefloorinarandomway.Afterfinishingthrowing,Stantriestofindthetopsticks,thatisthesestickssuchthatthereisnostickontopofthem.Stanhasnoticedthatthelastthrownstickisalwaysontopbuthewantstoknowallthesticksthatareontop.Stansticksarevery,verythinsuchthattheirthicknesscanbeneglected.InputInputconsistsofanumberofcases.Thedataforeach...
DescriptionWeallknowthatapairofdistinctpointsonaplanedefinesalineandthatapairoflinesonaplanewillintersectinoneofthreeways:1)nointersectionbecausetheyareparallel,2)intersectinalinebecausetheyareontopofoneanother(i.e.theyarethesameline),3)intersectinapoint.Inthisproblemyouwilluseyouralgebraicknowledgetocreateaprogramthatdetermineshowandwheretwolinesintersect.Yourprogramwillrepeatedlyreadinfourpo...
DescriptionGiven n segmentsinthetwodimensionalspace,writeaprogram,whichdeterminesifthereexistsalinesuchthatafterprojectingthesesegmentsonit,allprojectedsegmentshaveatleastonepointincommon.InputInputbeginswithanumber T showingthenumberoftestcasesandthen, T testcasesfollow.Eachtestcasebeginswithalinecontainingapositiveinteger n ≤100showingthenumberofsegments.Afterthat,n linescontai...
DescriptionMomanddadhaveaproblem:theirchild,Reza,neverputshistoysawaywhenheisfinishedplayingwiththem.TheygaveRezaarectangularboxtoputhistoysin.Unfortunately,Rezaisrebelliousandobeyshisparentsbysimplythrowinghistoysintothebox.Allthetoysgetmixedup,anditisimpossibleforRezatofindhisfavoritetoysanymore.Reza'sparentscameupwiththefollowingidea.Theyputcardboardpartitionsintothebox.EvenifRezak...
DescriptionCalculatethenumberoftoysthatlandineachbinofapartitionedtoybox.Momanddadhaveaproblem-theirchildJohnneverputshistoysawaywhenheisfinishedplayingwiththem.TheygaveJohnarectangularboxtoputhistoysin,butJohnisrebelliousandobeyshisparentsbysimplythrowinghistoysintothebox.Allthetoysgetmixedup,anditisimpossibleforJohntofindhisfavoritetoys. John'sparentscameupwiththefollowingidea.Th...
DescriptionFarmerJohncommandedhiscowstosearchfordifferentsetsofnumbersthatsumtoagivennumber.Thecowsuseonlynumbersthatareanintegerpowerof2.Herearethepossiblesetsofnumbersthatsumto7:1)1+1+1+1+1+1+12)1+1+1+1+1+23)1+1+1+2+24)1+1+1+45)1+2+2+26)1+2+4HelpFJcountallpossiblerepresentationsforagivenintegerN(1<=N<=1,000,000).给出一个N(1≤N≤10^6),使用一些2的若干次幂的数相加来求之.问有多少...
Mashmokh'sboss,Bimokh,didn'tlikeMashmokh.Sohefiredhim.MashmokhdecidedtogotouniversityandparticipateinACMinsteadoffindinganewjob.HewantstobecomeamemberofBamokh'steam.Inordertojoinhewasgivensomeprogrammingtasksandoneweektosolvethem.Mashmokhisnotaveryexperiencedprogrammer.Actuallyheisnotaprogrammeratall.Sohewasn'tabletosolvethem.That'swhyheaskedyoutohelphimwiththesetasks.Oneofthesetas...
近期评论