Divide By Power of Two
Python
Medium
3 views
Problem Description
Input has two integers x and k are provided (k>=0). Output floor(x / (2^k)) using right shift (for non-negative x).
Input Format
One line: x k.
Output Format
One integer result.
Official Solution
import sys
p=sys.stdin.read().strip().split()
if len(p)<2: sys.exit(0)
x=int(p[0]); k=int(p[1])
sys.stdout.write(str(x >> k))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!