UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#202335#3537. 序列cqzxz100893ms4300kbC++1.1kb2024-02-15 10:50:062024-02-15 12:33:13

answer

#include<bits/stdc++.h>
#define rg register
#define il inline
#define int long long
using namespace std;

const int p = 1e9 + 7, N = 200005;
int n, m, k, x, ans;
int a[N];
int f[N];

il void init(int n){
	f[0] = 1;
	for (int i = 1; i <= n; i++) f[i] = 1ll * f[i - 1] * i % p;
}

il int qpow(int a, int b){
	int ans = 1, base = a;
	while(b){
		if (b & 1) ans = 1ll * ans * base % p;
		base = 1ll * base * base % p;
		b >>= 1;
	}
	return ans;
}

il int C(int n, int m){
	if (m > n || m < 0) return 0;
	return 1ll * f[n] * qpow(f[m], p - 2) % p * qpow(f[n - m], p - 2) % p;
}

il int rd(){
	char c = getchar(); 
	int n = 0;
	while (c < '0' || c > '9'){ 
		c = getchar(); 
	}
	while (c >= '0' && c <= '9'){ 
		n = (n << 1) + (n << 3) + (c & 15); 
		c = getchar(); 
	}
	return n;
}

signed main(){
	n = rd();
	init(n);
	for (int i = 1; i <= n; i++) a[i] = rd();
	sort(a + 1, a + n + 1);
	int ans = 0;
	for (int i = 1; i <= n; i++){
		int res = C(i - 1, a[i] - 1);
		res %= p;
		int cnt = qpow(2, n - i);
		cnt %= p;
		ans = (ans % p + res * cnt % p) % p;
	}
	cout << ans;
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 5
Accepted
time: 0ms
memory: 1184kb

input:

15 8 6 14 11 4 9 15 14 15 9 14 12 3 6 13

output:

1

result:

ok single line: '1'

Test #2:

score: 5
Accepted
time: 1ms
memory: 1180kb

input:

15 10 9 3 3 2 4 10 10 14 13 14 3 10 1 10

output:

46732

result:

ok single line: '46732'

Test #3:

score: 5
Accepted
time: 0ms
memory: 1180kb

input:

15 3 4 2 13 8 15 8 13 11 6 3 2 9 9 3

output:

32999

result:

ok single line: '32999'

Test #4:

score: 5
Accepted
time: 0ms
memory: 1180kb

input:

15 9 9 10 12 8 8 11 14 6 5 6 13 9 11 6

output:

288

result:

ok single line: '288'

Test #5:

score: 5
Accepted
time: 0ms
memory: 1180kb

input:

15 3 2 15 6 12 1 15 12 5 10 13 4 5 9 6

output:

38637

result:

ok single line: '38637'

Test #6:

score: 5
Accepted
time: 0ms
memory: 1212kb

input:

2000 25 484 1870 583 668 1298 1198 1838 1248 567 1864 1118 1554 564 1303 1047 1053 960 1729 1932 196...

output:

385129497

result:

ok single line: '385129497'

Test #7:

score: 5
Accepted
time: 0ms
memory: 1212kb

input:

2000 34 1417 31 1345 46 1660 875 1911 518 1609 41 1402 1088 1120 1649 1214 1927 1602 645 589 162 161...

output:

44472341

result:

ok single line: '44472341'

Test #8:

score: 5
Accepted
time: 0ms
memory: 1212kb

input:

2000 1024 1019 1146 1656 1906 411 258 1698 1376 1730 998 806 1959 1347 1797 1035 1464 216 179 1618 1...

output:

477127421

result:

ok single line: '477127421'

Test #9:

score: 5
Accepted
time: 1ms
memory: 1216kb

input:

2000 904 1371 1577 708 325 661 1064 1928 1337 1980 1275 583 1688 1560 257 1281 789 1589 787 1875 176...

output:

409666345

result:

ok single line: '409666345'

Test #10:

score: 5
Accepted
time: 0ms
memory: 1212kb

input:

2000 736 1091 1058 755 653 1211 205 1131 1494 1153 1816 35 1455 1411 663 874 1851 510 494 1962 1668 ...

output:

962962192

result:

ok single line: '962962192'

Test #11:

score: 5
Accepted
time: 99ms
memory: 4296kb

input:

200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ...

output:

175895281

result:

ok single line: '175895281'

Test #12:

score: 5
Accepted
time: 95ms
memory: 4296kb

input:

200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ...

output:

175895281

result:

ok single line: '175895281'

Test #13:

score: 5
Accepted
time: 96ms
memory: 4300kb

input:

200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ...

output:

175895281

result:

ok single line: '175895281'

Test #14:

score: 5
Accepted
time: 99ms
memory: 4300kb

input:

200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ...

output:

175895281

result:

ok single line: '175895281'

Test #15:

score: 5
Accepted
time: 95ms
memory: 4300kb

input:

200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ...

output:

175895281

result:

ok single line: '175895281'

Test #16:

score: 5
Accepted
time: 86ms
memory: 4296kb

input:

200000 166590 20849 126411 133366 36333 18332 172547 57470 145664 110620 37556 113908 123961 195783 ...

output:

426667668

result:

ok single line: '426667668'

Test #17:

score: 5
Accepted
time: 58ms
memory: 4296kb

input:

200000 169672 89425 34124 104143 93288 70493 61048 192113 292 79680 52311 52428 142153 144390 91082 ...

output:

462091315

result:

ok single line: '462091315'

Test #18:

score: 5
Accepted
time: 88ms
memory: 4296kb

input:

200000 184655 166160 76584 90054 51931 198051 58297 90616 113758 140994 13505 93311 4251 53203 31173...

output:

697086497

result:

ok single line: '697086497'

Test #19:

score: 5
Accepted
time: 83ms
memory: 4296kb

input:

200000 80079 124181 170434 31758 99420 136529 30673 145269 111549 163488 37324 132314 122035 39583 1...

output:

512465333

result:

ok single line: '512465333'

Test #20:

score: 5
Accepted
time: 92ms
memory: 4296kb

input:

200000 83684 149238 26953 164914 50552 195667 72114 83448 182923 88943 196844 92388 134484 105724 63...

output:

335807702

result:

ok single line: '335807702'

Extra Test:

score: 0
Extra Test Passed