ACM的探索之Just Skip The Problem

-----------------心怀虔诚,奋勇前进,fighting!!!!!!

Problem Description:

 

inclusively:          包括一切地;包含地

simultaneously:   同时

index number   : 指数; 索引编号

if and only if:       当且仅当

-----Rough Translation:

Input:

Output:

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

 -------------------------------一会儿再来补充,我要变得更强丫!

分析:

最优的方案必然是每次询问一个位的具体值,一共有n个二进制位,方案数显然是n!。

复杂度O(min(n,P),P=1e6+3)

我的同学写的一个版本:

#include<cstdio>
#define LL long long
 
const int mod = 1e6+3;
int main()
{
    LL n;
    while(~scanf("%lld",&n)) 
    {
        if(n >= mod) puts("0");//此处mod可以改为41,因为之前已经有个数可以整除 
        else {                // 2009,7*7*41=2009;
            LL ans = 1;
            for(int i = n; i>1; i--) {
                ans = (ans*(i%mod))%mod;//ans=(ans%mod*i%mod)%mod;
            }
            printf("%lld
",ans);
        }
 
    }
    return 0;
 }
原文地址:https://www.cnblogs.com/dragondragon/p/11237849.html