結果

問題 No.811 約数の個数の最大化
ユーザー yasaijuiceryotayasaijuiceryota
提出日時 2019-04-12 21:54:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,597 bytes
コンパイル時間 1,586 ms
コンパイル使用メモリ 169,088 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 19:59:42
合計ジャッジ時間 2,386 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,356 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,356 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 5 ms
4,348 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 1 ms
4,352 KB
testcase_12 AC 2 ms
4,356 KB
testcase_13 AC 27 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
template<typename T>
T ncr(T left, T right) {
	right = min(left - right, right);
	T ans = 1;
	for (T i = 1; i <= right; i++) {
		ans = ans * (left - right + i) / i;
	}
	return ans;
}

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;


int main() {
	int N, K;
	vector<int> v;
	cin >> N >> K;

	int sub = N;
	for (int i = 2; i <= sub; i++) {
		if (sub % i == 0) {
			v.push_back(i);
			sub /= i;
			i--;
		}
	}
	debugv(v);
	int save = 1;
	int ans = 1;
	vector<bool> table(N, false);
	for (int i = 1; i < pow(2, v.size()) - 1; i++) {
		bitset<20> b(i);
		if (b.count() < K)
			continue;
		int num = 1;
		for (int j = 0; j < v.size(); j++) {
			if (b[j]) {
				num *= v[j];
			}
		}
		
		for (int i = 1; i*num < N; i++) {
			int p = 0;
			int snum = i * num;
			if (table[snum])continue;
			table[snum] = true;
			for (int j = 1; j*j <= snum; j++) {
				if (snum%j == 0) {
					p += 2;
					if (j*j == snum)
						p--;
				}
			}
			if (save < p) {
				save = p;
				ans = snum;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

0