結果

問題 No.2795 Perfect Number
ユーザー Vishal Kumar MishraVishal Kumar Mishra
提出日時 2024-06-28 21:55:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,424 bytes
コンパイル時間 2,035 ms
コンパイル使用メモリ 200,328 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-06-28 21:56:08
合計ジャッジ時間 8,767 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 TLE -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
// OM NAMAH SHIVAY

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key


#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long
const int inf = 1e18;


// int dx[4]={-1,0,1,0};
// int dy[4]={0,1,0,-1};

// int dx[8]={0,-1,-1,-1,0,1,1,1};
// int dy[8]={1,1,0,-1,-1,-1,0,1};

const int N = 200200;
const int mod = 1e9+7;
using ii = pair<int,int>;

//write on copy

void solver(){
    int n;cin>>n;
    int x = n;

    int sum = 1ll;
    int i = 2;

    for(;i*i<=n;i++)
    {
        if(n%i==0)
        {
            int cnt = 0;
            while(n%i==0)
            {
                cnt++;
                n/=i;
            }

            sum*=(pow(i,cnt+1)-1);
            sum/=(i-1);
        }

        if(sum>2*x)
        {
            cout<<"No"<<endl;return;
        }
    }

    if(n>1)
    {
        sum*=(pow(n,1+1)-1);
        sum/=(n-1);
    }

    if(sum==2*x)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

}


signed main()
{
    IOS
    //int _t;cin>>_t;while(_t--)
    solver();
    return 0;
}

#undef int
0