本文主要是介绍Just Skip The Problem,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Y_UME has just found a number xx in his right pocket. The number is a non-negative integer ranging from 00 to 2n−12n−1 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 ii-th question, you give him an integer yiyi ranging from 00 to 2n−12n−1 inclusively, and he will answer you if x&yix&yi equals to yiyi 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 xx 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 xx? You should output the number of methods modulo 106+3106+3.
Two methods differ if and only if they have different number of questions or there exsits some ii satisfying that the ii-th question of the first method is not equal to the ii-th of the second one.
Input
There are multiple test cases.
Each case starts with a line containing one positive integer n(n≤109)n(n≤109).
Output
For each test case, output one line containing an integer denoting the answer.
Sample Input
2
Sample Output
2
题意: 给定一个数n每次可以询问多个问题,询问为y,每次可以得到n与y位于之后与y的关系,最少几次询问可以确定n的值。
思路: 位于即看两个数的二进制形式每一位是否相同,同时为1则为1,只需把 n的二进制每一位找到即可,共n位n的阶乘种问法。
代码:
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=1e6+3;
int n,ans[mod+9];
int main()
{for(int i=ans[0]=1;i<mod;i++)ans[i]=ll(i)*ans[i-1]%mod;while(scanf("%d",&n)==1){if(n>=mod)printf("0\n");elseprintf("%d\n",ans[n]);}return 0;
}
这篇关于Just Skip The Problem的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!