結果

問題 No.2795 Perfect Number
コンテスト
ユーザー ManjushriMitra
提出日時 2024-06-29 11:38:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 585 bytes
コンパイル時間 1,651 ms
コンパイル使用メモリ 173,620 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2024-06-29 11:38:39
合計ジャッジ時間 4,970 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 TLE * 1 -- * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,m,n) for(int i=m; i<n; ++i)
#define repl(i,m,n) for(ll i=m; i<n; ++i)

vector<ll> divisor(ll N){
    vector<ll> res;
    for(ll i = 1LL; i*i <= N; ++i){
        if(N % i == 0){
            res.push_back(i);
            if(i*i != N) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main(){
    ll N;
    cin >> N;

    vector<ll> d = divisor(N);

    ll sum = 0LL;
    for(ll dd : d) sum += dd;

    cout << (sum == 2*N ? "Yes" : "No") << endl;

    return 0;
}
0