結果
| 問題 |
No.811 約数の個数の最大化
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2019-04-12 23:20:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 150 ms / 2,000 ms |
| コード長 | 757 bytes |
| コンパイル時間 | 668 ms |
| コンパイル使用メモリ | 74,056 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 06:18:34 |
| 合計ジャッジ時間 | 2,032 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int main() {
int n, k;
cin >> n >> k;
int r = -1;
ll m = 0;
for (int i = 1; i < n; i++) {
int t = i, s = n, y = 0;
ll c = 1;
for (int j = 2; j * j <= n; j++) {
int h = 0;
while (t % j == 0) {
if (s % j == 0) s /= j, y++;
t /= j, h++;
}
c *= h + 1;
}
if (s > 1 && t > 1 && s % t == 0) y++;
if (t > 1) c *= 2;
if (y >= k && c > m) {
m = c;
r = i;
}
}
cout << r << endl;
return 0;
}
merom686