結果

問題 No.3687 Coprime Count
コンテスト
ユーザー あるふぁ
提出日時 2026-09-06 20:15:59
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 612 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,048 ms
コンパイル使用メモリ 353,992 KB
実行使用メモリ 44,928 KB
最終ジャッジ日時 2026-09-06 20:16:13
合計ジャッジ時間 5,607 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 998244353;

int main(){
    int N, M, K;
    cin >> N >> M;
    K = min(N, M);
    vector<int> mu(K+1, 1);
    vector<bool> sq(K+1, false), is(K+1, true);
    is[0] = false;
    is[1] = false;

    for (int n = 2; n <= N; n++){
        if (!is[n]) continue;
        for (int m = n; m <= N; m += n) mu[m] *= -1, is[m] = false;
        if ((ll)n*n > N) continue;
        for (int m = n*n; m <= N; m += n*n) mu[m] = 0;
    }

    ll ans = 0;
    for (int n = 1; n <= K; n++) ans += (ll)mu[n]*(N/n)*(M/n);
    cout << ans << endl;
}
0