結果
| 問題 | No.2552 Not Coprime, Not Divisor |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-18 01:04:27 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 541 bytes |
| 記録 | |
| コンパイル時間 | 1,227 ms |
| コンパイル使用メモリ | 211,308 KB |
| 実行使用メモリ | 7,296 KB |
| 最終ジャッジ日時 | 2026-07-03 00:36:05 |
| 合計ジャッジ時間 | 2,551 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}