DescriptionGiveatreewithnvertices,eachedgehasalength(positiveintegerlessthan1001).Definedist(u,v)=Themindistancebetweennodeuandv.Giveanintegerk,foreverypair(u,v)ofverticesiscalledvalidifandonlyifdist(u,v)notexceedk.Writeaprogramthatwillcounthowmanypairswhicharevalidforagiventree.InputTheinputcontainsseveraltestcases.Thefirstlineofeachtestcasecontainstwointegersn,k.(n<=10000)Thefollowi...
近期评论