QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#79729#3724. Strange PrimeYangHHaoAC ✓121ms3380kbC++141.5kb2023-02-20 19:54:312023-02-20 19:54:32

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-20 19:54:32]
  • 评测
  • 测评结果:AC
  • 用时:121ms
  • 内存:3380kb
  • [2023-02-20 19:54:31]
  • 提交

answer

#include<bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
#define pii pair<int,int>
#define ll long long
#define il inline
#define fst first
#define scd second
#define reg register
#define err() cout<<"err "<<__LINE__<<endl,exit(0)
#define pot(args...) \
	GPT(#args),cout<<"  Line "<<__LINE__<<"\t: ", \
	PPT(args),cout<<"\n\n"
#define rep(i,s,t) for(int i=(s);i<=(t);++i)
#define irep(i,t,s) for(int i=(t);i>=(s);--i)
void PPT(){}
template<typename TYPE,typename... TYPES>
void PPT(const TYPE& x,const TYPES&... y){cout<<x<<' ',PPT(y...);}
void GPT(string nam){cout<<setw(29)<<nam;}
il int read(int x=0,int f=1){
    char ch=getchar();
    while(ch<'0'||ch>'9')f=(ch=='-'?-1:1),ch=getchar();
    while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return x*f;
}
il void write(int x){
    char F[200];
    int tmp=x>0?x:-x;
    if(x<0)putchar('-');
    if(x==0)putchar('0');
    int cnt=0;
    while(tmp>0){
	    F[cnt++]=tmp%10+'0';
        tmp/=10;
    }
    while(cnt>0)putchar(F[--cnt]);
}
const int P=999999956,mod=1e9+7;
int qp(int a,int b){
	int r=1;
	while(b){
		if(b&1)r=1ll*r*a%mod;
		a=1ll*a*a%mod;b>>=1;
	}
	return r;
}
int n;
void work(){
	int ans=1,tot=1;
	rep(i,1,n){
		int a;cin>>a;
		ans=1ll*ans*(P-a)%mod;
		tot=1ll*tot*a%mod;
		tot=mod-tot;
	}
	ans=(ans-tot)%mod;
	ans=1ll*ans*qp(P,mod-2)%mod;
	cout<<(ans%mod+mod)%mod<<'\n';
}
signed main(){
	ios::sync_with_stdio(false);
	while(cin>>n){
		work();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 121ms
memory: 3380kb

input:

10
2357 42596 7212 30898 43465 68984 60783 59520 53767 77560
10
39115 88080 83553 61736 90821 39690 13194 81396 38051 55993
10
95070 81321 71632 21071 10807 46105 66844 63678 47577 75132
10
43898 93215 26791 11849 61857 1423 76971 83489 52044 61325
10
22610 16613 90 53598 80110 42651 64942 67114 242...

output:

8747181
109223012
855771490
541976436
590061154
362989597
987338731
316507988
571293823
811262072
971678511
475746045
438611414
341241863
155506989
174497292
470085592
844919405
114498965
739370426
38587099
214008686
506810838
254574502
480440711
792847181
303917854
79001517
310250674
834963010
1907...

result:

ok 11305 numbers