UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#204333#3602. 最小公倍数drdilyor1009612ms112524kbC++972b2024-05-19 09:11:502024-05-19 12:02:08

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[1000005];
int pr[1000005];
int pw[1000005];
vector<pair<int,int> > dv[1000005];
int l;
bool b[1000005];
const int mod=1e9+7;
int qkp(int b,int p){
	if(p==0)return 1;
	int r=1;
	while(p){
		if(p&1)(r*=b)%=mod;
		(b*=b)%=mod;
		p/=2;
	}
	return r;
}
signed main(){
	for(int i=2;i<=1000000;i++){
		if(!b[i]){
			dv[i].push_back({i,1});
			pr[++l]=i;
			for(int j=i*2;j<=1000000;j+=i){
				b[j]=1;
				int x=j;
				int p=0;
				while(x%i==0){x/=i,p++;}
				dv[j].push_back({i,p});
			}
		}
	}
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		for(int j=0;j<(int)dv[a[i]].size();j++)pw[dv[a[i]][j].first]=max(pw[dv[a[i]][j].first],dv[a[i]][j].second);
	}
	int res=1;
	for(int i=1;i<=1000000;i++){
		//if(pw[i])cout<<i<<" "<<pw[i]<<"\n";
		res*=qkp(i,pw[i]);res%=mod;
	}
	cout<<res;
	return 0;
}

详细

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

Test #1:

score: 10
Accepted
time: 952ms
memory: 96988kb

input:

10000
2290 3392 196 1603 181826 420 10388 168315 370440 6360 458 1588 768 188160 17640 428760 30870 ...

output:

136554595

result:

ok single line: '136554595'

Test #2:

score: 10
Accepted
time: 764ms
memory: 96984kb

input:

10000
467712 12250 505344 261000 2016 2360 821280 519680 132160 2961 371200 141 26019 682080 5782 13...

output:

378784227

result:

ok single line: '378784227'

Test #3:

score: 10
Accepted
time: 699ms
memory: 96984kb

input:

10000
720 3630 91476 9240 287301 4860 186624 1008 1296 36864 36 933120 12705 43560 672 975744 20736 ...

output:

272469645

result:

ok single line: '272469645'

Test #4:

score: 10
Accepted
time: 678ms
memory: 101180kb

input:

10000
209411 813081 102149 219907 593611 24114 959730 305867 496529 635050 21890 102981 487777 98241...

output:

686427981

result:

ok single line: '686427981'

Test #5:

score: 10
Accepted
time: 861ms
memory: 101224kb

input:

10000
325539 329221 106895 882089 718673 502890 699009 489855 430685 939232 282330 630021 287868 584...

output:

357762046

result:

ok single line: '357762046'

Test #6:

score: 10
Accepted
time: 781ms
memory: 101276kb

input:

10000
376259 910770 887448 703054 67926 981667 695184 641139 364840 276118 318577 222469 896470 3783...

output:

54112396

result:

ok single line: '54112396'

Test #7:

score: 10
Accepted
time: 1304ms
memory: 112520kb

input:

1000000
492387 235422 924898 332532 192988 684636 499872 857831 331700 547597 579017 525316 696560 2...

output:

719239181

result:

ok single line: '719239181'

Test #8:

score: 10
Accepted
time: 1106ms
memory: 112520kb

input:

1000000
608515 751563 705451 994713 509537 130709 463343 41819 265855 851779 839457 85060 496650 774...

output:

411167767

result:

ok single line: '411167767'

Test #9:

score: 10
Accepted
time: 1360ms
memory: 112520kb

input:

1000000
691939 300407 710197 624191 858791 609486 268030 225807 200011 188665 132600 612100 329445 6...

output:

723701065

result:

ok single line: '723701065'

Test #10:

score: 10
Accepted
time: 1107ms
memory: 112524kb

input:

1000000
30518 196518 274071 359971 550121 204862 843967 173607 619138 690754 219513 171337 183499 54...

output:

227996544

result:

ok single line: '227996544'

Extra Test:

score: 0
Extra Test Passed