結果
| 問題 |
No.811 約数の個数の最大化
|
| コンテスト | |
| ユーザー |
izumo
|
| 提出日時 | 2019-04-13 00:51:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 1,632 bytes |
| コンパイル時間 | 2,324 ms |
| コンパイル使用メモリ | 169,952 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 06:32:06 |
| 合計ジャッジ時間 | 2,310 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()
template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}
const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)
// 素因数分解
vector<pii> prime_factor(int n){
vector<pii> res;
for(int i=2; i*i<=n; ++i){
if(n%i!=0){
continue;
}
int num=0;
while(n%i==0){
++num;
n/=i;
}
res.push_back(pii(i, num));
}
if(n!=1){
res.push_back(pii(n, 1));
}
return res;
}
int gcd(int a, int b){
if(b==0){
return a;
}
return gcd(b, a%b);
}
int num[114514];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
// cout<<setprecision(10)<<fixed;
int n, k;
cin>>n>>k;
int cnt=0, ans=0;
FOR(i, 1, n){
vector<pii> v1=prime_factor(gcd(i, n));
int tmp=0;
for(auto x : v1){
tmp+=x.second;
}
if(tmp<k){
continue;
}
vector<pii> v2=prime_factor(i);
tmp=1;
for(auto x : v2){
tmp*=x.second+1;
}
if(tmp>cnt){
cnt=tmp;
ans=i;
}
}
cout<<ans<<'\n';
return 0;
}
izumo