Facebook
From Walloping Capybara, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 103
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
  5. C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
  6. Code, Compile, Run and Debug online from anywhere in world.
  7.  
  8. *******************************************************************************/
  9. public class Main
  10. {
  11.         public static void main(String[] args) {
  12.            
  13.             int number = 0 , ans = 0 ;
  14.             int left = 0 , right = number ;
  15.             while (left <= right ){
  16.                 int mid = (left + right )/ 2 ;
  17.                 if (mid * mid <= number){
  18.                     ans = mid ;
  19.                     left = mid + 1 ;
  20.                 }
  21.                 else
  22.                 {
  23.                     right = mid - 1 ;
  24.                 }
  25.             }
  26.             System.out.print (ans);
  27.         }
  28. }
  29.