HDUOJ 6600 Just Skip The Problem

    技术2025-10-07  10

    HDUOJ 6600 Just Skip The Problem

    题目链接

    Problem Description

    Y_UME has just found a number x in his right pocket. The number is a non-negative integer ranging from 0 to 2 n − 1 2^{n−1} 2n1 inclusively. You want to know the exact value of this number. Y_UME has super power, and he can answer several questions at the same time. You can ask him as many questions as you want. But you must ask all questions simultaneously. In the i-th question, you give him an integer yi ranging from 0 to 2 n − 1 2^{n−1} 2n1 inclusively, and he will answer you if x&yi equals to yi or not. Note that each question you ask has a index number. Namely, the questions are ordered in certain aspect. Note that Y_UME answer all questions at the same time, which implies that you could not make any decision on the remaining questions you could ask according to some results of some of the questions.

    You want to get the exact value of x and then minimize the number of questions you will ask. How many different methods may you use with only minimum number of questions to get the exact value of x? You should output the number of methods modulo 1e6+3.

    Two methods differ if and only if they have different number of questions or there exsits some i satisfying that the i-th question of the first method is not equal to the i-th of the second one.

    Input

    There are multiple test cases.

    Each case starts with a line containing one positive integer n(n≤1e9).

    Output

    For each test case, output one line containing an integer denoting the answer.

    Sample Input

    2

    Sample Output

    2

    水题吧,就是题目意思比较难懂,大意是让你猜数字,每次可以问一个与运算,位运算敏感的童鞋立马想到了用 2 的幂次方去与,比如 2 k & x = 1 2^k\&x=1 2k&x=1 就证明 x x x 的二进制的第 k k k 位为1,那么只要对所有二进制位都判断一下即可,那么最小问题数就是 n n n,题目问方案数,求一个全排列即可,全排列有一个思维点就是当 n ≥ m o d n\geq mod nmod 时直接输出 0,AC代码如下:

    #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll mod=1e6+3; int main(){ ll n; while(~scanf("%lld",&n)){ if(n>=mod) printf("0\n"); else{ ll ans=1; for(ll i=1;i<=n;i++) ans=ans*i%mod; printf("%lld\n",ans); } } }
    Processed: 0.009, SQL: 9