結果
問題 | No.811 約数の個数の最大化 |
ユーザー | HIcoder |
提出日時 | 2023-07-04 22:21:57 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,827 bytes |
コンパイル時間 | 876 ms |
コンパイル使用メモリ | 85,328 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-25 21:43:14 |
合計ジャッジ時間 | 1,859 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 12 ms
4,380 KB |
testcase_03 | WA | - |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 3 ms
4,376 KB |
testcase_08 | AC | 6 ms
4,380 KB |
testcase_09 | AC | 14 ms
4,380 KB |
testcase_10 | AC | 5 ms
4,376 KB |
testcase_11 | AC | 4 ms
4,384 KB |
testcase_12 | AC | 4 ms
4,380 KB |
testcase_13 | AC | 82 ms
4,384 KB |
testcase_14 | AC | 7 ms
4,376 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:60:18: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 60 | for(auto [v,num]:primenum){ | ^
ソースコード
#include<iostream> #include<set> #include<algorithm> #include<vector> #include<string> #include<set> #include<map> #include<numeric> #include<queue> #include<cmath> using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair<int,int> P; typedef pair<int,P> PP; const ll MOD=1e9+7; vector<pair<ll,ll>> primediv(ll n){ vector<pair<ll,ll>> res; for(ll p=2;p*p<=n;p++){ if(n%p==0){ pair<ll,ll> tmp; tmp.first=p,tmp.second=0; while(n%p==0){ n/=p; tmp.second++; } res.push_back(tmp); } } if(n>1){ res.emplace_back(n,1); } return res; } int main(){ int N,K; cin>>N>>K; auto primenum=primediv(N); ll maxnum=0;//約数の個数のmax ll ans=0; for(int i=1;i<N;i++){ //cout<<"i="<<i<<endl; ll cntnum=1; ll k=0; ll tmpi=i; for(auto [v,num]:primenum){ if(tmpi%v==0){ ll t=0; while(tmpi%v==0){ t++; tmpi/=v; } k+=min(t,num); } } if(k>=K){ ll candnum=1; ll cand=i; for(ll d=2;d*d<=i;d++){ if(cand%d==0){ ll t=0; while(cand%d==0){ t++; cand/=d; } candnum*=(t+1); } } if(maxnum<candnum){ ans=i; maxnum=candnum; } //cout<<"ans="<<ans<<endl; //cout<<"maxnum="<<maxnum<<endl; } } cout<<ans<<endl; }