Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
169271 B班-陈行知 二进制计数游戏 C++ 解答错误 10 1 MS 248 KB 883 2024-08-20 16:12:32

Tests(1/10):


#include <iostream> #include <bits/stdc++.h> using namespace std; long long countBinaryNumbers(int n, long long s, long long t) { auto countOnes = [](long long num) { int count = 0; while (num > 0) { if (num % 2 == 1) { count++; } num /= 2; } return count; }; int numOnesS = countOnes(s); int numOnesT = countOnes(t); long long count = 0; for (int i = numOnesS; i <= numOnesT; i++) { long long comb = 1; for (int j = 1; j <= i; j++) { comb = comb * (n - j + 1) / j; } count += comb; } return count; } int main() { int n; long long s, t; cin >> n >> s >> t; long long result = countBinaryNumbers(n, s, t); cout << result << endl; return 0; }


测评信息: