結果

問題 No.2417 Div Count
ユーザー Moleigh-Lv563
提出日時 2023-08-12 14:18:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 937 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 173,284 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-11-19 18:30:40
合計ジャッジ時間 2,999 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 WA * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <numeric>
#include <unordered_map>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define i64 int_fast64_t

const i64 INF = INT64_MAX;
const i64 ERR = INT64_MIN;
const i64 MOD = 998244353;

template <typename T>
map<T, T> prime_factor(T n) {
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++) {
        T tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
        }
        ret[i] = tmp;
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

template <typename T>
T divisor_num(T N) {
    map<T, T> pf = prime_factor(N);
    T ret = 1;
    for (auto p : pf) {
        ret *= (p.second + 1);
    }
    return ret;
}

long long ans;

int main() {
  i64 N,K,haruka;
  cin>>N>>K;
  haruka=N-K;
  ans=divisor_num(haruka);
  if(K==0){
    cout<<ans<<endl;
  }else{
    cout<<ans-1<<endl;
  }
}
0