- [柳泉中学,龙凤苑中学]拔高班第三次训练
C 二进制数字
- @ 2025-3-18 17:17:26
#include <iostream>
#include <queue>
int look(int n) {
int count = 0;
std::queue<long long> q;
q.push(1);
while (!q.empty()) {
long long num = q.front();
q.pop();
if (num <= n) {
count++;
q.push(num * 10);
q.push(num * 10 + 1);
}
}
return count;
}
int main() {
int n;
std::cin >> n;
int result = look(n);
std::cout << result << std::endl;
return 0;
}
0 comments
No comments so far...