SRM 635 DIV 2 250 problem in topcoder

This is somehow easy comparing to other 500 point problem.

this is about a square root.




public class QuadraticLaw {

 public long getTime(long time){
  long number  = (long)Math.floor(Math.sqrt(time));
  for(long i=number; i>0; i--){
   if((i * i) + i <=  time){
    return i;
   }
  }
  return 0l;
 }
}

Comments

Popular posts from this blog

Project euler 169 found clue

Floyd-Warshall's algorithm