結果

問題 No.2480 Sequence Sum
ユーザー askr58askr58
提出日時 2023-09-22 21:39:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 500 ms
コード長 773 bytes
コンパイル時間 4,118 ms
コンパイル使用メモリ 260,636 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-10-04 12:33:50
合計ジャッジ時間 4,846 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,384 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0