ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#204335 | #3602. 最小公倍数 | smallstone | 100 | 5693ms | 40944kb | C++11 | 1014b | 2024-05-19 09:15:30 | 2024-05-19 12:02:32 |
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//using LL = __int128
#define N 1111111
#define mod 1000000007ll
ll npme[N], pme[111111], pos, minp[N], n, a[N], cnt[N], val[N];
void init(int v = 1000000){
for(int i = 2 ; i <= v ; i++){
val[i] = 1;
if(!npme[i]){
pme[++pos] = i;
minp[i] = i;
for(ll j = 1ll * i * i ; j <= v ; j += i)
if(!npme[j]){
npme[j] = true;
minp[j] = i;
}
}
}
}
void g(ll x){
unordered_map<int, ll> mp, v;
while(x > 1){
if(!v[minp[x]])
v[minp[x]] = 1;
mp[minp[x]]++;
v[minp[x]] = (v[minp[x]] * minp[x]) % mod;
x /= minp[x];
}
for(auto i : mp){
int u = i.first, v1 = i.second, v2 = v[u];
if(v1 > cnt[u]){
cnt[u] = v1;
val[u] = v2;
}
}
}
int main(){
init();
scanf("%lld", &n);
for(int i = 1 ; i <= n ; i++){
scanf("%lld", a + i);
g(a[i]);
}
ll ans = 1;
for(int i = 2 ; i <= 1000000 ; i++){
ans = (ans * val[i]) % mod;
}
cout << ans;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 50ms
memory: 25396kb
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: 47ms
memory: 25396kb
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: 39ms
memory: 25396kb
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: 50ms
memory: 29548kb
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: 58ms
memory: 29608kb
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: 58ms
memory: 29728kb
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: 1551ms
memory: 40944kb
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: 1065ms
memory: 40944kb
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: 1651ms
memory: 40944kb
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: 1124ms
memory: 40940kb
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