結果
問題 |
No.2552 Not Coprime, Not Divisor
|
ユーザー |
|
提出日時 | 2023-12-05 23:15:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 644 ms / 2,000 ms |
コード長 | 438 bytes |
コンパイル時間 | 2,040 ms |
コンパイル使用メモリ | 193,252 KB |
最終ジャッジ日時 | 2025-02-18 07:57:15 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) int totient(int x){ int ret = x; for(int p=2;p*p<=x;p++){ if(x%p==0){ ret -= ret/p; while(x%p==0) x/=p; } } if(x!=1) ret -= ret/x; return ret; } int main(){ ll n; cin>>n; ll ans=0; ans+=n*(n-1)/2; for(int i=2;i<=n;i++){ ans-=totient(i); } for(int i=2;i<=n;i++){ ans-=n/i-1; } cout<<ans<<endl; }