Skip to content

Commit a993758

Browse files
committed
Create 2109B-SliceToSurvive.cpp
1 parent 6258f66 commit a993758

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

2109B-SliceToSurvive.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <cstdio>
2+
#include <cmath>
3+
#include <algorithm>
4+
5+
int main(){
6+
7+
long t; scanf("%ld", &t);
8+
while(t--){
9+
long n, m, a, b; scanf("%ld %ld %ld %ld", &n, &m, &a, &b);
10+
long resA = ceil(log2(std::min(a, n - a + 1))) + ceil(log2(m)) + 1;
11+
long resB = ceil(log2(n)) + ceil(log2(std::min(b, m - b + 1))) + 1;
12+
printf("%ld\n", std::min(resA, resB));
13+
}
14+
15+
}

0 commit comments

Comments
 (0)