結果

問題 No.2417 Div Count
ユーザー WR
提出日時 2023-08-12 14:36:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 857 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 76,744 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-19 20:21:30
合計ジャッジ時間 1,941 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long A, B; cin >> A >> B;
    long long N = A - B;
    cin >> N;
    const auto &res = enum_divisors(N);
    int M = res.size();
    int ans = 0;
    for(int i = 0; i < M; i++){
        if(res[i] > B){
            ans++;
        }
    }
    cout << ans << endl;
    // for (int i = 0; i < res.size(); ++i) cout << res[i] << " ";
    // cout << endl;
}
0