QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#79653 | #3724. Strange Prime | Cring | WA | 99ms | 4132kb | C++20 | 1.1kb | 2023-02-20 18:42:36 | 2023-02-20 18:42:38 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define op(x) ((x&1)?x+1:x-1)
#define odd(x) (x&1)
#define even(x) (!odd(x))
#define lc(x) (x<<1)
#define rc(x) (lc(x)|1)
#define lowbit(x) (x&-x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
using namespace std;
const int MAXN=1e5+10,mod=1e9+7;
ll mypow(ll a,ll n){
if(!n)return 1;
ll tmp=mypow(a,n/2);tmp=tmp*tmp%mod;
if(n&1)tmp=tmp*a%mod;return tmp;
}
ll myinv(ll a){return mypow(a,mod-2);}
void add(ll& x,ll y){x=(x+y)%mod;}
void sub(ll& x,ll y){x=(x-y+mod)%mod;}
//
ll T,n,a[MAXN];
ll ans,P=1e10+19;
void solve(){
rep(i,1,n)cin>>a[i];
ans=1;
rep(i,1,n){
ll val=(mod-1)*a[i]%mod;
add(val,P%mod);
ans=ans*val%mod;
}
ll val=1,flag=1;
rep(i,1,n){
val=val*(mod-1)%mod*a[i]%mod;
flag&=(a[i]>0);
}
sub(ans,val);
ans=ans*myinv((P%mod))%mod;
if(flag){
if(odd(n))sub(ans,1);
else add(ans,1);
}
cout<<ans<<"\n";
}
int main(){
ios::sync_with_stdio(false);
while(cin>>n)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 99ms
memory: 4132kb
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:
8747182 109223013 855771491 541976437 590061155 362989598 987338732 316507989 571293824 811262073 971678512 475746046 438611415 341241864 155506990 174497293 470085593 844919406 114498966 739370427 38587100 214008687 506810839 254574503 480440712 792847182 303917855 79001518 310250675 834963011 1907...
result:
wrong answer 1st numbers differ - expected: '8747181', found: '8747182'