UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#187511#3369. 好的集合21355510011998ms8988kbC++111.9kb2023-10-02 10:12:532023-10-02 12:36:44

answer

#include<bits/stdc++.h>
using namespace std;
long long read(){
    long long x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
long long a[1000010],cnt=1,sum=0,ans=1,n,t,po=169,p[]={4,9,25,49,121,169,289,361,529,841,961,1369,1681,1849,2209,2809,3481,3721,4489,5041,5329,6241,6889,7921,9409,10201,10609,11449,11881,12769,16129,17161,18769,19321,22201,22801,24649,26569,27889,29929,32041,32761,36481,37249,38809,39601,44521,49729,51529,52441,54289,57121,58081,63001,66049,69169,72361,73441,76729,78961,80089,85849,94249,96721,97969,100489,109561,113569,120409,121801,124609,128881,134689,139129,143641,146689,151321,157609,160801,167281,175561,177241,185761,187489,192721,196249,201601,208849,212521,214369,218089,229441,237169,241081,249001,253009,259081,271441,273529,292681,299209,310249,316969,323761,326041,332929,344569,351649,358801,361201,368449,375769,380689,383161,398161,410881,413449,418609,426409,434281,436921,452929,458329,466489,477481,491401,502681,516961,528529,537289,546121,552049,564001,573049,579121,591361,597529,619369,635209,654481,657721,674041,677329,683929,687241,703921,727609,734449,737881,744769,769129,776161,779689,786769,822649,829921,844561,863041,877969,885481,896809,908209,935089,942841,954529,966289,982081,994009,1018081};
long long f(long long x){
	for(long long i = 0; i < po; i++){
		while(x%p[i]==0)x/=p[i];
		if(x==1)return 1;
	}
	return x;
}
int main(){
	n=read(),t=read();
	for(long long i=0;i<n;i++)a[i]=read(),a[i]=f(a[i]);
	sort(a,a+n);
	for(long long i=1;i<n;i++){//--------------------------------- O(n)
		if(a[i]!=a[i-1]){
			sum++;
			ans*=cnt;
			ans%=998244353;
			cnt=0;
		}
		cnt++;
		cnt%=998244353;
	}
	sum++;
	ans*=cnt;
	ans%=998244353;
	cnt=0;
	cout<<sum<<" ";
	if(t)cout << ans;
	return 0;
}

详细

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

Test #1:

score: 10
Accepted
time: 0ms
memory: 1172kb

input:

18 0
17 11 9 13 5 7 2 7 3 2 14 11 11 13 2 12 5 7

output:

9 

result:

ok single line: '9 '

Test #2:

score: 10
Accepted
time: 0ms
memory: 1172kb

input:

18 1
3 11 7 13 8 5 17 11 3 11 7 3 13 3 4 9 8 4

output:

8 288

result:

ok single line: '8 288'

Test #3:

score: 10
Accepted
time: 954ms
memory: 8972kb

input:

1000000 0
32768 2048 2048 1 512 16 32 1024 4 2 8192 16 64 1 2048 64 64 4 512 4096 64 8192 32 32 2 20...

output:

2 

result:

ok single line: '2 '

Test #4:

score: 10
Accepted
time: 933ms
memory: 8976kb

input:

1000000 1
32768 128 32 64 32768 8192 16 16384 8192 128 32 16 1 2 16384 8 1 256 2048 8192 2048 32768 ...

output:

2 438909986

result:

ok single line: '2 438909986'

Test #5:

score: 10
Accepted
time: 1752ms
memory: 8988kb

input:

1000000 0
979031 926587 888983 930437 976091 947647 766639 896803 731807 988661 804803 832681 948593...

output:

33014 

result:

ok single line: '33014 '

Test #6:

score: 10
Accepted
time: 1740ms
memory: 8984kb

input:

1000000 1
981961 810487 931067 978031 890843 950179 966727 886819 970903 968333 846919 930079 998951...

output:

32966 703377747

result:

ok single line: '32966 703377747'

Test #7:

score: 10
Accepted
time: 1744ms
memory: 8972kb

input:

1000000 0
813221 946733 860311 960637 845749 925019 818969 963643 972683 897007 948943 949439 967961...

output:

40066 

result:

ok single line: '40066 '

Test #8:

score: 10
Accepted
time: 1726ms
memory: 8988kb

input:

1000000 1
974387 928513 935149 971357 925823 925387 997811 987809 985399 943799 885881 897373 916469...

output:

40244 687316703

result:

ok single line: '40244 687316703'

Test #9:

score: 10
Accepted
time: 1583ms
memory: 8196kb

input:

900000 0
932537 984701 916141 870593 903359 986941 850033 979063 967859 948797 946511 965623 807629 ...

output:

39081 

result:

ok single line: '39081 '

Test #10:

score: 10
Accepted
time: 1566ms
memory: 8208kb

input:

900000 1
841427 999043 920957 776077 864341 859223 805639 981797 880021 858673 911873 759149 849869 ...

output:

39239 97996837

result:

ok single line: '39239 97996837'

Extra Test:

score: 0
Extra Test Passed