結果
| 問題 |
No.847 Divisors of Power
|
| コンテスト | |
| ユーザー |
soy
|
| 提出日時 | 2019-08-07 16:44:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 942 bytes |
| コンパイル時間 | 847 ms |
| コンパイル使用メモリ | 74,288 KB |
| 最終ジャッジ日時 | 2025-01-07 10:57:58 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 RE * 1 |
| other | AC * 4 WA * 18 TLE * 4 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
vector<pair<long long int, int>> t;
int ans = 1;
long int k, n, m;
int main() {
void counting(int, int);
void specialcount();
int count = 0;
cin >> n >> k >> m;
if (n == 1) {
specialcount();
return 0;
}
if (n % 2 == 0) {
for (; n % 2 == 0; n /= 2) {
count++;
}
t.push_back(make_pair(2, k * count));
}
for (int i = 3; n != 1; i += 2) {
if (i > m)
break;
if (n % i == 0) {
for (count = 0; n % i == 0; n /= i) {
count++;
}
t.push_back(make_pair(i, k * count));
}
}
counting(0, 1);
cout << ans;
return 0;
}
void counting(int a, int px) {
int x = px;
if (a + 1 < size(t))
counting(a + 1, x);
for (int i = 0; i < t[a].second; i++) {
x *= t[a].first;
if (x > m) {
return;
}
else {
ans++;
if (a + 1 < size(t)) {
counting(a + 1, x);
}
}
}
}
void specialcount() {
if (m == 0)
cout << 0;
else
cout << 1;
}
soy