容易发现只需要分别求出 然后再求每个 可以匹配的数量,最后加起来就好了。
#include <bits/stdc++.h>
using namespace std ;
long long n , cnt , x = 1 ;
int main() {
cin >> n ;
while(x < n) {
cnt += (n / x + 1) / 2 ;
x *= 4 ;
}
cout << cnt ;
return 0 ;
}
总结
难度:中位橙。
时间复杂度: 。
空间复杂度: 。
暂无评论