【hdu6600】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

解题思路:
这是一道逻辑思维题。从题目可知,他让你求出最小的方案数。
1.直接令x=0,为了判断这一信息,对于所有含有多个1的yi,必然是无用的,答案至少为n且不能含有多位1的y
2.令yi=2^(i-1),由此发现一定可以得到x每一位的答案,即答案最多为n。
因此,发现方案数就是n!,当n≥mod时答案一定为0,时间复杂度为o§
标程:
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define N 100005
#define M 100005
#define INF 0x3f3f3f3f
#define sz(x) ((int)x.size())
#define lson(x) (x<<1)
#define rson(x) (x<<1|1)
#define mp(a,b) make_pair(a, b)
#define endl ‘\n’
#define lowbit(x) (x&-x)

using namespace std;
typedef long long ll;
typedef double db;
const int mod = 1e6+3;
int n;

/** fast read **/
template
inline void read(T &x) {
x = 0; T fg = 1; char ch = getchar();
while (!isdigit(ch)) {
if (ch == ‘-’) fg = -1;
ch = getchar();
}
while (isdigit(ch)) x = x*10+ch-‘0’, ch = getchar();
x = fg * x;
}

int main()
{
while(~scanf("%lld",&n))
{
if(n>=mod||n==0)
{
cout << “0” << endl;
}
else
{
long long int f = 1;
for(int i = 1 ; i <= n ; i++)
{
f=f*i%mod;
}
cout << f << endl;
}
}
return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值