結果
| 問題 | No.3687 Coprime Count |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-06 20:18:30 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 203 ms / 2,000 ms |
| + 709µs | |
| コード長 | 596 bytes |
| 記録 | |
| コンパイル時間 | 4,983 ms |
| コンパイル使用メモリ | 353,184 KB |
| 実行使用メモリ | 43,520 KB |
| 最終ジャッジ日時 | 2026-09-06 20:18:45 |
| 合計ジャッジ時間 | 5,379 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#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> is(K+1, true);
is[0] = false;
is[1] = false;
for (int n = 2; n <= K; n++){
if (!is[n]) continue;
for (int m = n; m <= K; m += n) mu[m] *= -1, is[m] = false;
if ((ll)n*n > K) continue;
for (int m = n*n; m <= K; 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;
}