hdu 2019多校 Just Skip The Problem

Portal Title: the Just Skip of The Problem
ideas:
n-<= 1E9.
The optimal solution, namely to carry out inquiries each, a total of n bits. Program number -> n!
As the title makes you the total number of programs% 1e6 + 3.
I can think of, n> = 1e6 + 3, when all is 0. Pretreatment hit the front of the table like.
Code:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e6+10;
const int mod=1e6+3;
ll a[maxn];
int main()
{
    a[1]=1;
    for(int i=2;i<=1e6+3;i++)
    {
        a[i]=a[i-1]*i%mod;
    }
    ll n;
    while(~scanf("%lld",&n))
    {
        if(n>=1e6+3)printf("0\n");
        else printf("%lld\n",a[n]);
    }
    return 0;
}

Guess you like

Origin www.cnblogs.com/gugudesu/p/11241206.html