abc--280--D
阿新 • • 發佈:2022-12-04
題目大意
找到一個最小的n,使得n的階乘能整除k
思路
將它化為一堆的質數,然後滿足這些質數至少需要多大的數
最後這個找最大的數的時候,直接暴力就可以了,因為不會有很多個質數
程式碼
#include <bits/stdc++.h> using namespace std; using pii=pair<int,int>; #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define TT int _=read();while(_--) #define int long long //#define double long double #define endl '\n' const int inf=1e18; const int M=1e6+5; inline int read(){ int 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; } inline void print(int x) { if(x<0){putchar('-');x=-x;} if(x/10)print(x/10); putchar(x%10+'0'); } int a[M]; char s[M],ss[M]; vector<int>v; //首先計算質因子,然後呢 map<int,int>mp; signed main() { int k=read(); for(int i=2;i*i<=k;i++) while(k%i==0)k/=i,mp[i]++; if(k!=1)mp[k]++; deque<int>q; int ans=0; for(auto [x,y]:mp) { int cnt=0,i; for(i=1;i<=100;i++) { int tmp=i; cnt++; while(tmp%x==0)tmp/=x,cnt++; if(cnt>=y)break; }//尋找一下滿足這個質數的數量,至少需要多大的數 ans=max(ans,i*x); } cout<<ans; return 0; }