QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#556730 | #8526. Polygon II | spdarkle | WA | 186ms | 5772kb | C++14 | 1.4kb | 2024-09-10 20:25:48 | 2024-09-10 20:25:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 2505
#define M 55
#define int long long
const int p=1e9+7;
int power(int a,int b){
int ans=1;
while(b){
if(b&1)ans=ans*a%p;
a=a*a%p;b>>=1;
}
return ans;
}
int f[M][N<<1],n,m,a[N],b[N],jc[N],inv[N],pw[N];
int C(int n,int m){
if(n<m)return 0;
return jc[n]*inv[m]%p*inv[n-m]%p;
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
jc[0]=1;
for(int i=1;i<=1500;++i)jc[i]=jc[i-1]*i%p;
inv[1500]=power(jc[1500],p-2);pw[0]=1;
for(int i=1;i<=1500;++i)pw[i]=pw[i-1]*((p+1)>>1)%p;
for(int i=1500;i;--i)inv[i-1]=inv[i]*i%p;
cin>>n;
for(int i=1;i<=n;++i)cin>>a[i],b[a[i]]++;
for(int i=50;i>=0;--i)b[i]+=b[i+1];
for(int i=0;i<n;++i){
for(int j=0,x=1;j<=i;++j,x=-x){
f[0][i]+=x*C(n,j)%p*power(i-j+1,n)%p;
}
// cout<<f[0][i]<<" ";
f[0][i]=(f[0][i]*inv[n]%p+p)%p;
}
for(int i=n-1;i;--i)f[0][i]=f[0][i]-f[0][i-1];
for(int i=1;i<=50;++i){
for(int j=0;j<=2000;++j)if(f[i-1][j])for(int k=0;k<=b[i];++k){
(f[i][j+k>>1]+=f[i-1][j]*C(b[i],k)%p*pw[b[i]]%p)%=p;
}
}
int ans=1;
for(int i=1;i<=n;++i){
int w=f[a[i]][0]%p;
for(int j=a[i]+1;j<=50;++j)w=w*pw[b[j]]%p;
ans=ans+p-w;
}
ans=(ans%p+p)%p;
cout<<ans<<"\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3864kb
input:
3 0 2 0
output:
166666668
result:
ok 1 number(s): "166666668"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3884kb
input:
3 0 0 0
output:
500000004
result:
ok 1 number(s): "500000004"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
3 5 6 7
output:
208333335
result:
ok 1 number(s): "208333335"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5736kb
input:
3 0 25 50
output:
889268532
result:
ok 1 number(s): "889268532"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3868kb
input:
10 39 11 25 1 12 44 10 46 27 15
output:
913863330
result:
ok 1 number(s): "913863330"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
57 43 22 3 16 7 5 24 32 25 16 41 28 24 30 28 10 32 48 41 43 34 37 48 34 3 9 21 41 49 25 2 0 36 45 34 33 45 9 42 29 43 9 38 34 44 33 44 6 46 39 22 36 40 37 19 34 3
output:
400729664
result:
ok 1 number(s): "400729664"
Test #7:
score: 0
Accepted
time: 2ms
memory: 5772kb
input:
100 44 32 6 6 6 44 12 32 6 9 23 12 14 23 12 14 23 49 6 14 32 23 49 9 32 24 23 6 32 6 49 23 12 44 24 9 14 6 24 44 24 23 44 44 49 32 49 12 49 49 24 49 12 23 3 14 6 3 3 6 12 3 49 24 49 24 24 32 23 32 49 14 3 24 49 3 32 14 44 24 49 3 32 23 49 44 44 9 23 14 49 9 3 6 44 24 3 3 12 44
output:
32585394
result:
ok 1 number(s): "32585394"
Test #8:
score: 0
Accepted
time: 48ms
memory: 3960kb
input:
1000 2 27 0 0 27 0 2 0 27 0 27 27 0 0 0 0 0 2 0 27 0 2 2 0 27 27 0 0 0 27 2 2 2 27 0 2 27 2 0 2 27 0 0 27 0 27 0 0 27 2 27 2 2 27 2 27 0 0 27 0 27 0 2 27 2 2 0 27 27 27 27 0 27 0 27 0 2 2 0 2 2 27 0 0 27 0 0 27 0 2 27 27 2 27 2 0 0 2 27 27 27 27 27 27 2 2 0 2 2 0 2 2 0 27 0 27 2 2 0 27 27 0 0 27 2 2...
output:
94588769
result:
ok 1 number(s): "94588769"
Test #9:
score: 0
Accepted
time: 186ms
memory: 4084kb
input:
1000 40 14 47 3 32 18 3 49 22 23 32 18 23 24 18 32 23 39 32 27 49 49 22 50 50 22 23 47 14 47 50 32 22 24 49 49 18 22 18 22 50 3 32 47 40 3 39 22 24 47 32 49 49 22 32 39 14 49 39 3 32 22 24 18 39 49 24 18 40 23 23 49 39 39 18 39 27 49 14 27 27 14 18 24 39 22 40 50 18 18 18 39 39 18 23 23 22 3 49 47 2...
output:
626481946
result:
ok 1 number(s): "626481946"
Test #10:
score: 0
Accepted
time: 134ms
memory: 4068kb
input:
1000 28 32 35 9 21 11 43 23 45 15 23 2 8 3 39 41 31 9 45 35 27 14 40 28 31 9 31 9 9 40 8 6 27 43 3 27 23 49 27 6 28 25 11 9 15 27 38 27 12 28 25 2 15 27 45 6 27 1 21 38 1 25 27 21 49 31 31 14 39 39 8 39 40 28 15 31 21 14 43 38 11 8 8 23 9 11 15 2 11 39 32 14 28 15 40 49 27 9 23 9 9 6 21 2 2 1 14 11 ...
output:
644443122
result:
ok 1 number(s): "644443122"
Test #11:
score: -100
Wrong Answer
time: 140ms
memory: 4124kb
input:
972 39 15 23 0 40 29 43 47 6 9 30 9 2 8 19 9 45 25 26 38 33 18 6 33 44 48 24 8 4 16 33 42 33 31 36 33 13 16 3 12 21 19 1 30 24 23 43 35 0 33 31 32 23 31 36 12 26 0 29 48 28 33 28 28 3 49 9 5 29 8 29 28 49 41 33 49 5 49 6 9 50 25 39 11 1 36 6 44 10 34 32 31 25 31 36 36 3 9 50 35 47 43 25 46 30 18 5 2...
output:
347106073
result:
wrong answer 1st numbers differ - expected: '684920840', found: '347106073'