結果
| 問題 |
No.2552 Not Coprime, Not Divisor
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-18 01:04:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 2,000 ms |
| コード長 | 541 bytes |
| コンパイル時間 | 1,937 ms |
| コンパイル使用メモリ | 193,732 KB |
| 最終ジャッジ日時 | 2025-02-17 22:25:53 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
assert(1 <= n && n <= 1000000);
vector<int> r(n + 1);
for(int i = 0; i <= n; i++){
r[i] = i;
}
for(int i = 2; i <= n; i++){
if(r[i] != i) continue;
for(int j = i; j <= n; j += i){
r[j] -= r[j] / i;
}
}
long long ans = 0;
for(int y = 1; y <= n; y++){
ans += ((n / y) - 1) * (r[y] - 1);
}
cout << ans << endl;
}