結果

問題 No.826 連絡網
ユーザー ooaiu
提出日時 2025-09-02 23:02:37
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 3,325 ms
コンパイル使用メモリ 281,300 KB
実行使用メモリ 7,840 KB
最終ジャッジ日時 2025-09-02 23:02:43
合計ジャッジ時間 4,681 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, p;
    cin >> n >> p;
    vector<int> ps;
    for (int64_t x = 2; x * x <= p; x++) {
        if (p % x == 0) {
            while (p % x == 0) {
                ps.push_back(x);
                p /= x;
            }
        }
    }
    if (p != 1) ps.push_back(p);
    ps.erase(unique(ps.begin(), ps.end()), ps.end());
    int lpf = ps.front();
    vector<int> vis(n);
    for (int g = 1; g <= n; g++) {
        if ((int64_t)g * lpf <= n) {
            vis[g] = 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans += vis[i];
    cout << ans << "\n";
}
0