QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#79707#3724. Strange PrimelichenghanWA 55ms5796kbC++141.4kb2023-02-20 19:28:212023-02-20 19:28:22

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:28:22]
  • 评测
  • 测评结果:WA
  • 用时:55ms
  • 内存:5796kb
  • [2023-02-20 19:28:21]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <cstdlib>
#define int long long
using namespace std;
const int p=1e10+19;
const int mod=1e9+7;
// FAST IO
//#define FREAD_USED
inline char gc() {
	#ifndef FREAD_USED
	return getchar();
	#else
	const int size=100005;
	static char buf[size],*p1=buf+size,*p2=buf+size;
	if(p1==p2)p2=(p1=buf)+fread(buf,1,size,stdin);
	return p1==p2?-1:*p1++;
	#endif
}
template<typename t=int> inline t read() {
	char ch=gc();
	t sum=0,s=1;
	while(ch<'0'||ch>'9'){
		if((ch=gc())=='-')s=-1;
		if(ch==-1) exit(0);
	}
	while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=gc();
	return sum*s;
}
template<typename t> inline void write(t x){
	if(x<0) putchar('-'),x=-x;
	if(x<10){
		putchar(x+48);
		return;
	}
	write(x/10);
	putchar(x%10+48);
}
//FAST IO END
const int N=1e5+100;
int n,a[N];
int pre[N],suf[N];
signed main(){
	while(true){
		n=read();
		for(int i=1;i<=n;i++){
			a[i]=read();
		}
//		puts("hi");
		pre[0]=1;
		for(int i=1;i<=n;i++){
			pre[i]=pre[i-1]*(p-a[i])%mod;
		}
//		puts("1");
		suf[n+1]=1;
		for(int i=n;i;i--){
			suf[i]=suf[i+1]*a[i]%mod;
		}
//		puts("2");
//		for(int i=1;i<=n;i++){
//			write(pre[i]);putchar(' ');write(suf[i]);putchar('\n');
//		}
		int ans=0;
		for(int i=n;i>=1;i--){
			ans+=pre[i-1]*suf[i+1]%mod*(i%2!=n%2?-1:1);
			ans=(ans%mod+mod)%mod;
		}
//		puts("hi");
		write(ans);
		puts("");
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 55ms
memory: 5796kb

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:

778439891
640324425
822878165
522117176
327598292
405194868
460482757
239120615
374352453
689715078
617578796
938936254
36552649
563328290
273327964
854754865
296169918
194147101
918763428
934289416
546417737
784529981
173463048
310981046
285834969
836024622
134535793
590691685
611373105
965339794
4...

result:

wrong answer 1st numbers differ - expected: '8747181', found: '778439891'