牛客 QQ6 geohash编码
概述
https://www.nowcoder.com/practice/46bd43f043c54013a67816d0a2946506
二分法
笑死,没想到 ACM 模式也有比较方便的情况。
#include <iostream>
using namespace std;
int main() {
int n; cin >> n;
int count = 6;
int l = -90, r = 90;
while (count--) {
int m = (l + r) / 2;
if (n >= m) {
cout << 1;
l = m;
} else {
cout << 0;
r = m;
}
}
}
Links: 牛客-qq06-geohash编码