Advertisement
chillurbrain

2. Сложность двоичного поиска.

May 25th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Main {
  5.     public static void main(String args[]) {
  6.         try (PrintWriter out = new PrintWriter(System.out)) {
  7.             Scanner in = new Scanner(System.in);
  8.            
  9.             int n = in.nextInt();
  10.             int x = 2;
  11.             int res = 1;
  12.             while (x < n) {
  13.                 x *= 2;
  14.                 res++;
  15.             }
  16.             out.print(res);
  17.         } catch(Exception e) {
  18.             System.out.println("Exception: " + e);
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement