結果

問題 No.2417 Div Count
ユーザー WRWR
提出日時 2023-08-12 14:04:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,451 bytes
コンパイル時間 2,149 ms
コンパイル使用メモリ 200,484 KB
実行使用メモリ 330,268 KB
最終ジャッジ日時 2024-04-30 04:53:24
合計ジャッジ時間 6,163 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}else{return false;}}
template<typename T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}else{return false;}}
/* ASCII
[0:48],[1:49],[2:50],[3:51],[4:52],[5:53],[6:54],[7:55],[8:56],[9:57],
[A:65],[B:66],[C:67],[D:68],[E:69],[F:70],[G:71],[H:72],[I:73],[J:74],[K:75],[L:76],[M:77],
[N:78],[O:79],[P:80],[Q:81],[R:82],[S:83],[T:84],[U:85],[V:86],[W:87],[X:88],[Y:89],[Z:90],
[a:97],[b:98],[c:99],[d:100],[e:101],[f:102],[g:103],[h:104],[i:105],[j:106],[k:107],[l:108],[m:109],
[n:110],[o:111],[p:112],[q:113],[r:114],[s:115],[t:116],[u:117],[v:118],[w:119],[x:120],[y:121],[z:122]
*/


// 素因数分解
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;
}
/*  divisor_num(n)
    入力:整数 n
    出力:nの約数の個数
    計算量:O(√n)
*/
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;
}


int main(void){
    int N, K; cin >> N >> K;
    int X = N - K;
    cout << divisor_num(X) - 1 + (K == 0 ? 1 : 0)<< endl;
}
0