P4626 一道水题 II
作者:互联网
大家都知道,对于两个数 \(a,b\)的\(lcm\),只要求去每个质数因数的较大的幂乘起来就行了。然后卡卡时
#include<cstdio>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<cmath>
#include<stack>
#include<algorithm>
#include<bitset>
using namespace std;
template<class T>inline void read(T &x)
{
x=0;register char c=getchar();register bool f=0;
while(!isdigit(c))f^=c=='-',c=getchar();
while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
if(f)x=-x;
}
template<class T>inline void print(T x)
{
if(x<0)putchar('-'),x=-x;
if(x>9)print(x/10);
putchar('0'+x%10);
}
int n;
int prime[5600000];
bool vis[100000001];
int mod=100000007;
int po(int bas,int m){
int res=1;
while(m){
if(m&1){
res*=bas;
}
bas*=bas;
m>>=1;
}
return res;
}
int cnt;
long long ans=1;
int main(){
read(n);
double logn=log(n);
for(int i=2;i<=n;++i){
if(vis[i]==0){
prime[++cnt]=i;
ans=(ans*po(i,floor(logn/log(i))))%mod;
}
for(register int j=1;j<=cnt&&prime[j]*i<=n;++j){
vis[prime[j]*i]=1;
if(i%prime[j]==0){
break;
}
}
}
cout<<ans;
return 0;
}
标签:bas,水题,P4626,int,res,II,while,isdigit,include 来源: https://www.cnblogs.com/For-Miku/p/15522642.html