結果
問題 | No.811 約数の個数の最大化 |
ユーザー | chocopuu |
提出日時 | 2019-04-13 01:10:56 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 91 ms / 2,000 ms |
コード長 | 1,765 bytes |
コンパイル時間 | 1,873 ms |
コンパイル使用メモリ | 172,304 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 06:32:33 |
合計ジャッジ時間 | 2,937 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
5,248 KB |
testcase_01 | AC | 3 ms
5,376 KB |
testcase_02 | AC | 81 ms
5,376 KB |
testcase_03 | AC | 3 ms
5,376 KB |
testcase_04 | AC | 3 ms
5,376 KB |
testcase_05 | AC | 3 ms
5,376 KB |
testcase_06 | AC | 6 ms
5,376 KB |
testcase_07 | AC | 9 ms
5,376 KB |
testcase_08 | AC | 36 ms
5,376 KB |
testcase_09 | AC | 39 ms
5,376 KB |
testcase_10 | AC | 24 ms
5,376 KB |
testcase_11 | AC | 80 ms
5,376 KB |
testcase_12 | AC | 19 ms
5,376 KB |
testcase_13 | AC | 91 ms
5,376 KB |
testcase_14 | AC | 91 ms
5,376 KB |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54, from main.cpp:1: In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]', inlined from 'int main()' at main.cpp:58:11: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'id' may be used uninitialized [-Wmaybe-uninitialized] 202 | { return _M_insert(__n); } | ~~~~~~~~~^~~~~ main.cpp: In function 'int main()': main.cpp:43:15: note: 'id' was declared here 43 | int ans=0,id; | ^~
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define fi first #define se second #define rep(i,s,n) for(int i = s;i<n;i++) #define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--) #define all(v) (v).begin(),(v).end() #define chmin(a,b) a=min((a),(b)) #define chmax(a,b) a=max((a),(b)) #define endl '\n' #define IOS() ios_base::sync_with_stdio(0);cin.tie(0) typedef long long ll; typedef pair<int,int>pint; typedef vector<int>vint; typedef vector<pint>vpint; const ll MOD=1000000007,INF=1e18; int dx[]={0,0,1,-1},dy[]={-1,1,0,0}; typedef pair<int,pint>P2; int N,K; vector<pair<long long, long long> > prime_factorize(long long n) { vector<pair<long long, long long> > res; for (long long p = 2; p * p <= n; ++p) { if (n % p != 0) continue; int num = 0; while (n % p == 0) { ++num; n /= p; } res.push_back(make_pair(p, num)); } if (n != 1) res.push_back(make_pair(n, 1)); return res; } signed main() { IOS(); cin>>N>>K; auto v=prime_factorize(N); vint cnt(100010,0); for(auto e:v)cnt[e.fi]=e.se; int ans=0,id; rep(i,1,N){ auto tmp=prime_factorize(i); int t=0,sum=1; for(auto e:tmp){ sum*=e.se+1; t+=min(e.se,cnt[e.fi]); } if(t>=K){ if(ans<sum){ ans=sum; id=i; } } } cout<<id<<endl; return 0; }