結果
| 問題 |
No.811 約数の個数の最大化
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-14 00:44:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 849 ms / 2,000 ms |
| コード長 | 1,124 bytes |
| コンパイル時間 | 4,524 ms |
| コンパイル使用メモリ | 239,484 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-14 00:44:54 |
| 合計ジャッジ時間 | 9,032 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:35:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
35 | for(auto[a,b]:A)mp[a]=b;
| ^
main.cpp:39:25: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
39 | for(auto[a,b]:B)mp2[a]=b;
| ^
main.cpp:41:25: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
41 | for(auto[k,v]:mp)cnt+=min(v,mp2[k]);
| ^
main.cpp:44:33: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
44 | for(auto[a,b]:B)ans*=(b+1);
| ^
main.cpp:48:15: warning: 'm' may be used uninitialized [-Wmaybe-uninitialized]
48 | cout<<m<<endl;
| ^
main.cpp:30:17: note: 'm' was declared here
30 | int M=0,m;
| ^
ソースコード
#include<bits/stdc++.h>
#include <atcoder/all>
#ifdef LOCAL
#include <debug_print.hpp>
#define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (static_cast<void>(0))
#endif
using namespace atcoder;
using mint=modint1000000007;
using namespace std;
using ll=long long;
using ul=unsigned long long;
int dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
int dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
using Graph=vector<vector<int>>;
ll op(ll a,ll b){return min(a,b);}
ll e(){return 2e9;}
vector<pair<long long,int>>prime(long long N){
vector<pair<long long,int>>ans;
for(long long i=2;i*i<=N;i++){
int cnt=0;
while(N%i==0)cnt++,N/=i;
ans.push_back({i,cnt});
}
if(N!=1)ans.push_back({N,1});
return ans;
}
int main(){
int M=0,m;
int N,K;
cin>>N>>K;
vector<pair<ll,int>>A=prime(N);
map<int,int>mp;
for(auto[a,b]:A)mp[a]=b;
for(int i=2;i<N;i++){
vector<pair<ll,int>>B=prime(i);
map<int,int>mp2;
for(auto[a,b]:B)mp2[a]=b;
int cnt=0;
for(auto[k,v]:mp)cnt+=min(v,mp2[k]);
int ans=1;
if(cnt>=K){
for(auto[a,b]:B)ans*=(b+1);
if(M<ans)m=i,M=ans;
}
}
cout<<m<<endl;
}