QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#291183#3267. 分手是祝愿MoRanSky100 ✓22ms5000kbC++23896b2023-12-26 05:16:382023-12-26 05:16:38

Judging History

This is the latest submission verdict.

  • [2023-12-26 05:16:38]
  • Judged
  • Verdict: 100
  • Time: 22ms
  • Memory: 5000kb
  • [2023-12-26 05:16:38]
  • Submitted

answer

#include <iostream>
#include <cstdio>

using namespace std;

typedef long long LL;

const int N = 1e5 + 5, P = 100003;

int n, k, a[N], inv[N], f[N], cnt;

int main() {
	scanf("%d%d", &n, &k);
	inv[1] = 1;
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
	}
	for (int i = 2; i <= n; i++) {
		inv[i] = (LL)(P - P / i) * inv[P % i] % P;
	}
	for (int i = n; i; i--) {
		f[i] = ((LL)i * inv[n] % P + (LL)(n - i) * inv[n] % P * (f[i + 1] + 1) % P) * n % P * inv[i] % P;
	}
	for (int i = n; i; i--) {
		if (a[i]) {
			++cnt;
			for (int j = 1; j * j <= i; j++) {
				if (i % j == 0) {
					a[j] ^= 1;	
					if (i / j != j) a[i / j] ^= 1;
				} 
			}
		}
	}
	int ans = 0;
	if (k < cnt) {
		ans = k;
		for (int i = cnt; i > k; i--)
			ans = (ans + f[i]) % P;
	} else ans = cnt;
	for (int i = 1; i <= n; i++)
		ans = (LL)ans * i % P;
	printf("%d\n", ans);
}

詳細信息

Test #1:

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

input:

4 4
0 1 1 0

output:

48

result:

ok single line: '48'

Test #2:

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

input:

4 3
1 1 1 0

output:

72

result:

ok single line: '72'

Test #3:

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

input:

6 6
1 1 1 1 1 1

output:

3600

result:

ok single line: '3600'

Test #4:

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

input:

7 1
0 0 1 1 0 1 1

output:

55229

result:

ok single line: '55229'

Test #5:

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

input:

5 5
0 1 0 0 1

output:

240

result:

ok single line: '240'

Test #6:

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

input:

5 3
0 0 0 0 0

output:

0

result:

ok single line: '0'

Test #7:

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

input:

39 39
1 0 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 0 1 1 1 1 0 0 1 0 1 1 0

output:

3958

result:

ok single line: '3958'

Test #8:

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

input:

45 34
0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 0 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 1

output:

58701

result:

ok single line: '58701'

Test #9:

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

input:

62 62
1 1 1 1 0 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 1 1 0 0 0 0 1 0 1 0 0 0 1 1 0 1 1 1 1 0 0 1 0 0 1 1 1 0 0 1 0 1 1 0 1 0 0 1 0 0 0 1

output:

74689

result:

ok single line: '74689'

Test #10:

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

input:

9 3
0 0 0 0 1 0 0 0 0

output:

25739

result:

ok single line: '25739'

Test #11:

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

input:

503 503
1 1 1 0 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 1 1 0 1 0 0 0 1 0 0 1 1 0 1 1 0 1 0 1 1 0 0 0 1 0 1 1 0 0 1 0 1 1 1 1 1 0 0 1 0 1 0 0 ...

output:

7933

result:

ok single line: '7933'

Test #12:

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

input:

962 658
0 0 0 1 1 1 0 0 1 1 1 0 0 0 1 0 0 1 1 1 1 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1 0 1 0 1 1 0 0 1 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 1 0 0 1 0 0 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 ...

output:

55348

result:

ok single line: '55348'

Test #13:

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

input:

724 724
0 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 0 1 1 0 1 1 0 1 0 1 1 1 0 1 0 0 1 0 0 1 0 0 1 0 1 1 0 1 0 1 1 1 0 1 1 0 1 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 1 0 0 1 0 1 1 1 0 1 1 1 0 0 0 0 1 1 1 1 1 ...

output:

69048

result:

ok single line: '69048'

Test #14:

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

input:

881 9
1 0 1 1 1 1 0 0 1 0 0 0 0 0 1 0 0 1 1 0 1 0 1 0 0 1 1 0 0 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 0 1 0 0 1 0 0 0 1 1 0 0 1 1 0 0 1 0 1 0 0 0 1 1 1 0 0 0 1 1 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 0 1 0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 1 1 0 1 0 1 1 1 0 1 0 0 0 1 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 1 1 0 0 1 ...

output:

95266

result:

ok single line: '95266'

Test #15:

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

input:

668 668
1 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1 0 1 1 1 0 1 0 1 0 1 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1 0 1 0 1 1 1 1 1 0 1 1 0 1 1 0 1 1 1 0 1 1 0 1 1 0 0 1 0 1 1 1 0 0 0 1 1 1 1 1 0 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 1 0 0 1 1 1 1 1 1 0 1 0 0 1 0 1 1 0 0 0 1 1 0 ...

output:

33628

result:

ok single line: '33628'

Test #16:

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

input:

505 3
0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 1 0 1 1 0 1 0 0 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 0 1 0 0 1 0 0 1 1 1 1 1 0 1 1 1 1 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 1 1 1 0 0 0 0 0 1 0 1 0 1 1 0 1 0 1 ...

output:

75577

result:

ok single line: '75577'

Test #17:

score: 5
Accepted
time: 2ms
memory: 3880kb

input:

8933 8933
0 0 1 1 0 0 0 1 1 0 1 1 0 0 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 1 1 0 1 1 0 0 1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 0 1 0 0 1 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 0 0 0 0 0 0 ...

output:

31893

result:

ok single line: '31893'

Test #18:

score: 5
Accepted
time: 15ms
memory: 4604kb

input:

63525 7516
1 1 0 0 1 1 1 0 0 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 1 1 1 1 1 0 1 1 1 1 1 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 1 0 0 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 1 1 0 1 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 1 0 0 1 1 0 1 1 1 0 1 1 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 1 0 1...

output:

38712

result:

ok single line: '38712'

Test #19:

score: 5
Accepted
time: 16ms
memory: 4604kb

input:

64931 64931
1 1 0 1 1 1 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 0 0 1 1 0 0 0 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 0 1 0 0 1 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 0 1 1 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 1 0 1 0 0 1 0 ...

output:

12510

result:

ok single line: '12510'

Test #20:

score: 5
Accepted
time: 22ms
memory: 5000kb

input:

96495 72757
1 0 0 1 1 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 0 1 0 0 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 1 0 0 1 0 1 0 0 0 0 1 0 1 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 0 0 0 1 1 1 0 1 0 0 0 1 0 0 1 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 1 0 1 1 0 1 1 0 0 1 1 1 1 1 0 1 0 0 0 0 1 0 1 0 1 ...

output:

71132

result:

ok single line: '71132'