結果

問題 No.847 Divisors of Power
ユーザー CleyLCleyL
提出日時 2022-12-30 23:00:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 885 ms
コンパイル使用メモリ 88,896 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-17 03:51:53
合計ジャッジ時間 2,532 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <vector>

using namespace std;

vector<pair<long long,long long>> X;

int solve(int ind,long long nw, long long m){
  if(ind == X.size())return 1;
  int c = 0;
  int ans = 0;
  while(c <= X[ind].second && nw <= m){
    ans += solve(ind+1,nw,m);

    nw *= X[ind].first;
    c++;
  }
  return ans;
}

int main(){
  long long n,k,m;cin>>n>>k>>m;
  map<long long,long long> A;
  for(int i = 2; n >= i*i; i++){
    int tmp = 0;
    while(n%i == 0){
      tmp++;
      n/=i;
    }
    if(tmp){
      A[i] = tmp*k;
    }
  }
  if(n != 1){
    A[n] = k;
  }
  for(auto x: A){
    X.push_back({x.first,x.second});
  }

  cout << solve(0,1,m) << endl;
  
}
0