結果

問題 No.811 約数の個数の最大化
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2019-04-13 01:39:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,799 bytes
コンパイル時間 1,553 ms
コンパイル使用メモリ 171,804 KB
実行使用メモリ 31,760 KB
最終ジャッジ日時 2023-10-13 09:27:11
合計ジャッジ時間 2,836 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,136 KB
testcase_01 AC 5 ms
8,316 KB
testcase_02 AC 95 ms
31,760 KB
testcase_03 AC 4 ms
8,128 KB
testcase_04 AC 4 ms
8,172 KB
testcase_05 AC 5 ms
8,696 KB
testcase_06 AC 9 ms
10,024 KB
testcase_07 AC 13 ms
11,444 KB
testcase_08 AC 39 ms
18,640 KB
testcase_09 AC 48 ms
21,392 KB
testcase_10 AC 27 ms
15,916 KB
testcase_11 AC 84 ms
28,084 KB
testcase_12 AC 25 ms
15,840 KB
testcase_13 AC 96 ms
28,696 KB
testcase_14 AC 88 ms
27,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/





int N, K;
int A[101010];
map<int, int> B[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;

	rep(i, 1, N + 1) A[i] = i;
	rep(p, 2, N + 1) for (int i = p; i <= N; i += p) while (A[i] % p == 0) {
		B[i][p]++;
		A[i] /= p;
	}

	int ans = 0, ma = -1;
	rep(M, 1, N) {
		int k = 0;
		fore(p, B[N]) k += min(p.second, B[M][p.first]);
		if (k < K) continue;

		int yaku = 1;
		fore(p, B[M]) yaku *= p.second + 1;
		if (ma < yaku) {
			ans = M;
			ma = yaku;
		}
	}
	cout << ans << endl;
}
0