結果

問題 No.2417 Div Count
ユーザー futamegawa
提出日時 2023-08-12 13:48:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 596 bytes
コンパイル時間 628 ms
コンパイル使用メモリ 63,744 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-19 16:13:59
合計ジャッジ時間 1,704 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 3 WA * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using ll = long long;
using llu = long long unsigned;

using namespace std;

// nの約数を全て出力する関数
ll countDivisors(int n) {
    ll count = 0;
    // 1からnまでの整数で、nを割り切れるものを探す
    for (int i = 1; i*i <= n; i++) {
        // nをiで割った余りが0なら、iはnの約数
        if (n % i == 0) {
            count++;
        }
    }
    return count+1;
}


int main() {
    ll N, K;
    cin >> N >> K;

    ll tmp = N-K;
    ll result = countDivisors(tmp);
    cout << result << endl; return 0;
}
0