QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#88398#3267. 分手是祝愿tricyzhkx100 ✓10ms4660kbC++14908b2023-03-16 09:53:382023-03-16 09:53:41

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-16 09:53:41]
  • Judged
  • Verdict: 100
  • Time: 10ms
  • Memory: 4660kb
  • [2023-03-16 09:53:38]
  • Submitted

answer

# include <bits/stdc++.h>
using namespace std;
const int mod=100003;
typedef long long ll;
int a[100010],f[100010][2];
ll inv[100010];
ll power(ll a,int b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}
int main()
{
	int n,k,c=0,fac=1;
	cin>>n>>k;
	inv[0]=inv[1]=1;
	for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod,fac=(ll)fac*i%mod;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=n;i>=1;i--)
		for(int j=2*i;j<=n;j+=i)
			a[i]^=a[j];
	for(int i=1;i<=n;i++) c+=a[i];
	if(c<=k) return cout<<(ll)c*fac%mod<<endl,0;
	f[n][1]=f[n-1][1]=1;f[n-1][0]=mod-1;
	for(int i=n-1;i>k;i--)
	{
		f[i-1][0]=((ll)n*f[i][0]+(ll)(mod-n+i)*f[i+1][0]+mod-n)%mod*inv[i]%mod;
		f[i-1][1]=((ll)n*f[i][1]+(ll)(mod-n+i)*f[i+1][1])%mod*inv[i]%mod;
	}
	ll v=(k-f[k][0]+mod)*power(f[k][1],mod-2)%mod;
	cout<<(v*f[c][1]+f[c][0])%mod*fac%mod<<endl;
	return 0;
}

詳細信息

Test #1:

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

input:

4 4
0 1 1 0

output:

48

result:

ok single line: '48'

Test #2:

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

input:

4 3
1 1 1 0

output:

72

result:

ok single line: '72'

Test #3:

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

input:

6 6
1 1 1 1 1 1

output:

3600

result:

ok single line: '3600'

Test #4:

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

input:

7 1
0 0 1 1 0 1 1

output:

55229

result:

ok single line: '55229'

Test #5:

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

input:

5 5
0 1 0 0 1

output:

240

result:

ok single line: '240'

Test #6:

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

input:

5 3
0 0 0 0 0

output:

0

result:

ok single line: '0'

Test #7:

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

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: 2ms
memory: 3672kb

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: 1ms
memory: 3452kb

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: 2ms
memory: 3676kb

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: 2ms
memory: 3416kb

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: 2ms
memory: 3424kb

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: 2ms
memory: 3456kb

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: 1ms
memory: 3688kb

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: 2ms
memory: 3400kb

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: 2ms
memory: 3444kb

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: 3688kb

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: 9ms
memory: 4544kb

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: 7ms
memory: 4188kb

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: 10ms
memory: 4660kb

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'