#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    
    int count = 0;
    for (int x = 0; x <= n; x++) {
        if ((x ^ (2 * x) ^ (3 * x)) == 0) {
            count++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}
给定一个整数 n求出0∼n之间满足 x xor 2×x xor 3×x=0 的整数 x 有多少个。【输入】输入只有一行该行包含一个整数n 0≤n≤106 。【输出】x 的个数。用c++做

原文地址: https://www.cveoy.top/t/topic/h6Ta 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录