結果
問題 | No.847 Divisors of Power |
ユーザー | takumi152 |
提出日時 | 2019-07-05 22:03:57 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 938 bytes |
コンパイル時間 | 954 ms |
コンパイル使用メモリ | 90,720 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2024-04-16 07:21:00 |
合計ジャッジ時間 | 5,729 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 3 ms
5,376 KB |
testcase_15 | AC | 1,551 ms
8,704 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 3 ms
5,376 KB |
testcase_19 | AC | 5 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 358 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | TLE | - |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 2 ms
5,376 KB |
ソースコード
#include <iostream> #include <set> #include <stack> #include <algorithm> #include <utility> using namespace std; typedef long long int ll; typedef pair<ll, int> Pli; set<ll> getDivisorSet(ll n) { set<ll> divisor; ll k = 1; while (k * k <= n) { if (n % k == 0) { divisor.insert(k); divisor.insert(n / k); } k++; } return divisor; } int main(){ ll N, K, M; cin >> N >> K >> M; set<ll> divisor = getDivisorSet(N); set<ll> powerDivisor; stack<Pli> st; for (ll x : divisor) st.push(Pli(x, K)); while (!st.empty()) { Pli now = st.top(); st.pop(); if (now.second <= 0) continue; if (now.first > M) continue; auto it = powerDivisor.find(now.first); if (it != powerDivisor.end()) continue; powerDivisor.insert(now.first); for (ll x : divisor) st.push(Pli(now.first * x, now.second - 1)); } int ans = powerDivisor.size(); cout << ans << endl; return 0; }