結果
| 問題 | No.2480 Sequence Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-22 21:39:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 500 ms |
| コード長 | 773 bytes |
| コンパイル時間 | 4,164 ms |
| コンパイル使用メモリ | 251,664 KB |
| 最終ジャッジ日時 | 2025-02-17 00:27:43 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
vector<ll> primes(ll n){
vector<ll> ans;
vector<bool> isprime(n+1,true);
for(int i=2;i<=n;i++){
if(!isprime[i])continue;
else{
ans.push_back(i);
for(int j=2;j<=n/i;j++){
isprime[i*j]=false;
}
}
}
return ans;
}
int main()
{
vector<ll> ps=primes(100000);
ll n;
cin>>n;
ll n0=n;
ll ans=1;
for(ll x:ps){
if(n%x==0){
ll cnt=1;
while(n%x==0){
n/=x;
cnt++;
}
ans*=cnt;
}
}
if(n>1)ans*=2;
cout<<n0-ans<<endl;
return 0;
}