Just Skip The Problem(2019 Multi-University Training Contest 2)

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 21 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 0 to 2n 1 (2的n次方减1) 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 106 + 3(10的6次方+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≤109)
Output
For each test case, output one line containing an integer denoting the answer.
Sample Input
2
Sample Output
2
(翻译:你刚刚在他的右口袋里找到一个数字X。该数字是一个非负整数,范围从0到2n1(包括0和2n1)。你想知道这个数字的确切值。你有超能力,他可以同时回答几个问题。你可以问他任意多的问题。但你必须同时问所有的问题。在第i个问题中,你给他一个0到2n1的整数yi,如果x&yi等于yi,他会回答你。请注意,您提出的每个问题都有一个索引号。也就是说,问题在某些方面是有序的。注意,你必须同时回答所有的问题,这意味着你不能根据一些问题的结果对剩下的问题做出任何决定。 你想要得到x的精确值,然后最小化你要问的问题的数量。您可以使用多少种不同的方法,只需最少的问题就可以得到x的精确值?您应该输出模块106+3的方法数。 如果两种方法的问题数量不同,或者存在一些我认为第一种方法的第i个问题不等于第二种方法的第i个问题,那么这两种方法就不同了。
输入
有多个测试用例。 每种情况都以包含一个正整数n(n≤109)的行开始。
输出
对于每个测试用例,输出一行包含表示答案的整数。
例子
标准输入:2 标准输出:2

题意思路:考察了与运算,举个列子: 8的二进制是1000 7的二进制是0111
1000
0111 &运算中1&1=1,1&0=0,0&0=0 并且按位置对应运算的,也就是说第一位和第一位运算,其他类推 所以可以得出0000,故输出的是0。重要的是规律。 当n=2时只有范围0~3,当x=3(二进制为11)时yi=01和yi=10时,x与yi进行&运算得yi; 当n=3时发现当x=111,yi=001,yi=010.yi=100,yi=110,yi=101,yi=111,有6种方法。以此类推…得出结论。所求方法数为n的阶乘。
代码:

#include <iostream>
#include <cstring>
#include <stdio.h>
typedef long long ll;
using namespace std;
int MOD = 1e6+3;//le6就是10的6次方
ll a[1000005];
int main()
{
    int ans = 1,k = 1;
    ll n;
    for(ll i = 1; i <= 1000003; i++)
    {
        ans = (ans*i) % MOD;
        a[i] = ans;
        k++;
        //cout << ans << " ";
        //if(k % 7 == 0)
            //cout << endl;
    }
    while(~scanf("%lld",&n))
    {
        if(n >= 1000003)
            printf("0\n");
        else
            printf("%lld\n",a[n]);
    }
    return 0;
}

感悟:思维题不要想的太难。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值