Algorithm Analysis
The value under given constraints fits into a 32-bit signed integer typeint
. It is known that the power of two can be calculated by left shift: . Using the left shift, we calculatethe sum as (1 << k) + (1 << n)
.
Algorithm Implementation
Read the input data. Calculate and output the answer.
scanf("%d %d",&k,&n); res = (1 << k) + (1 << n); printf("%d\n", res);
Python implementation
k,n = map(int,input().split()) res = (1 << k) + (1 << n) print(res)