結果
問題 | No.847 Divisors of Power |
ユーザー | batsumaru |
提出日時 | 2019-07-05 22:51:32 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,239 bytes |
コンパイル時間 | 1,649 ms |
コンパイル使用メモリ | 177,700 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-07-29 00:02:45 |
合計ジャッジ時間 | 3,430 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,384 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 1 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 1 ms
4,380 KB |
testcase_13 | AC | 2 ms
4,380 KB |
testcase_14 | AC | 2 ms
4,376 KB |
testcase_15 | AC | 3 ms
4,380 KB |
testcase_16 | AC | 1 ms
4,380 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 2 ms
4,380 KB |
testcase_19 | AC | 1 ms
4,376 KB |
testcase_20 | AC | 2 ms
4,376 KB |
testcase_21 | AC | 2 ms
4,380 KB |
testcase_22 | AC | 2 ms
4,376 KB |
testcase_23 | AC | 2 ms
4,380 KB |
testcase_24 | AC | 3 ms
4,380 KB |
testcase_25 | AC | 1 ms
4,380 KB |
testcase_26 | AC | 2 ms
4,380 KB |
testcase_27 | AC | 2 ms
4,376 KB |
testcase_28 | AC | 2 ms
4,380 KB |
testcase_29 | AC | 1 ms
4,380 KB |
ソースコード
#include <bits/stdc++.h> #define DUMP(x) cout << #x << " = " << (x) << endl; #define FOR(i, m, n) for(int i = m; i < n; i++) #define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- ) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) #define FOREACH(x,a) for(auto& (x) : (a) ) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; const ll INF = 1e18; /* テンプレートここまで */ map<ll, ll> mp; ll ans = 0; ll n, k, m; void dec_prime(ll n){ ll a = 2; while(n > 1){ if(a*a > n){ mp[n]++; break; } if(n%a == 0){ while(n%a == 0){ mp[a]++; n /= a; } a = 2; }else{ a++; } } } bool dfs(ll t, ll pos, vector<vector<ll>>& p){ if(t > m) return false; if(pos == p.size()){ ans++; return true; } ll cur = t; REP(i, p[pos][1]+1){ bool b = dfs(cur, pos+1, p); if(!b) break; cur *= p[pos][0]; } return true; } int main() { cin >> n >> k >> m; if(n==1){ cout << 1 << endl; return 0; } dec_prime(n); vector<vector<ll>> p; if(mp.size() == 0){ p.push_back({n, k}); } FOREACH(x,mp){ p.push_back({x.first, x.second * k}); } dfs(1, 0, p); cout << ans << endl; }