zoukankan      html  css  js  c++  java
  • LightOJ 1067

    题意:http://www.lightoj.com/volume_showproblem.php?problem=1067

    a/b%mod=a*(b^(mod-2))%mod 表示a乘b的(mod-2)次方 mod是素数
    即s[n]/(s[n-m]*s[m])%mod==s[n]*pow(s[n-m],mod-2)*pow(s[m],mod-2)%mod
    因为幂比较大 所以要用大指数幂的公式

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<iostream>
    #include<queue>
    #include<map>
    #include<math.h>
    #include<string>
    #include<vector>
    using namespace std;
    #define INF 0x3f3f3f3f
    #define LL long long
    #define N 1000006
    int mod =1000003;
    LL a[N];
    LL poww(LL a,LL b)
    {
        LL c=1;
        while(b)
        {
            if(b&1) c=c*a%mod;
            b=b/2;
            a=a*a%mod;
        }
        return c;
    }
    LL C(int n,int m)
    {
        return a[n]*poww(a[m],mod-2)%mod*poww(a[n-m],mod-2)%mod;
    }
    int main()
    {
        a[0]=1;
        for(int i=1;i<N;i++)
            a[i]=a[i-1]*i%mod;
        int T,t=1;
        scanf("%d",&T);
        while(T--)
        {
            int n,m;
            scanf("%d%d",&n,&m);
            printf("Case %d: %lld
    ",t++,C(n,m));
        }
        return 0;
    }
  • 相关阅读:
    @bzoj
    @bzoj
    @codeforces
    @codeforces
    @bzoj
    @codeforces
    @codeforces
    @codeforces
    @NOIP2018
    反转字符串--C和Python
  • 原文地址:https://www.cnblogs.com/a719525932/p/7716648.html
Copyright © 2011-2022 走看看