问题标题:
一道ACM水题,还可以怎么简化呢?DescriptionAprimenumberisanaturalnumberwhichhasexactlytwodistinctnaturalnumberdivisors:1anditself.Thefirstprimenumberis2.Canyouwriteaprogramthatcomputesthenthprimenumber,givena
问题描述:
一道ACM水题,还可以怎么简化呢?
Description
Aprimenumberisanaturalnumberwhichhasexactlytwodistinctnaturalnumberdivisors:1anditself.Thefirstprimenumberis2.Canyouwriteaprogramthatcomputesthenthprimenumber,givenanumbern
杜列波回答:
传统法优化后.intprime(intn){inti;doublet;if(n%2!=0||n==2){if(n==2)return1;else{t=sqrt(n);//#includefor(i=3;it)...
点击显示
英语推荐
热门英语推荐