【JZOJ4928】【NOIP2017提高组模拟12.18】A

题目描述

这里写图片描述

数据范围

对于100%的数据,n<=100000,1<=A[i]<=5000

=w=

Ans=1ai

代码

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define ll long long
using namespace std;
const char* fin="aP1.in";
const char* fout="aP1.out";
const ll inf=0x7fffffff;
const ll maxn=100007,mo=998244353;
ll n,i,j,k;
ll a[maxn],fact[maxn];
ll ans;
ll qpower(ll a,ll b){
    ll c=1;
    while (b){
        if (b&1) c=c*a%mo;
        a=a*a%mo;
        b>>=1;
    }
    return c;
}
ll N(ll v){
    return qpower(v,mo-2);
}
ll read(){
    ll x=0;
    char ch=getchar();
    while (ch<'0' || ch>'9') ch=getchar();
    while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
    return x;
}
int main(){
    scanf("%lld",&n);
    j=1;
    for (i=1;i<=n;i++) j=(j*N(read()))%mo;
    printf("%lld",j);
    return 0;
}

=o=

拿几个较小的数据推一推便发现规律。

posted @ 2016-12-20 16:59  hiweibolu  阅读(149)  评论(0编辑  收藏  举报