結果

問題 No.847 Divisors of Power
ユーザー CleyLCleyL
提出日時 2022-12-30 17:44:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 679 bytes
コンパイル時間 1,002 ms
コンパイル使用メモリ 88,888 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 23:33:58
合計ジャッジ時間 2,805 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

using namespace std;

vector<pair<int,int>> 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