D - Factorial and Multiple -- ATCODER
D - Factorial and Multiple
https://atcoder.jp/contests/abc280/tasks/abc280_d
思路
Code
https://blog.csdn.net/wp_fxy/article/details/128179159
https://www.cnblogs.com/Lanly/p/16950858.html#d---factorial-and-multiple-abc280-d
#include <bits/stdc++.h> using namespace std; #define ll long long ll k; map<ll,ll> mymap; int main(){ cin >> k; ll kk=k; for(ll i=2;i*i<=kk;++i){ while(k%i==0){ mymap[i]++; k/=i; } } if(k!=1) mymap[k]++; ll ans=0; for(map<ll,ll>::iterator it=mymap.begin();it!=mymap.end();++it){ ll p=it->first,q=it->second; ll mans=0,cnt=0; while(cnt<q){ mans+=p; ll m=mans; while(m%p==0){ cnt++; m/=p; } } ans=max(ans,mans); } cout << ans << endl; return 0; }
出处:http://www.cnblogs.com/lightsong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。