結果

問題 No.2782 メルセンヌ数総乗
ユーザー askr58
提出日時 2024-06-14 22:53:46
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 4,749 ms
コンパイル使用メモリ 307,320 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-14 22:53:53
合計ジャッジ時間 5,543 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
const int m=32;
ll gcd(ll x,ll y){
  if(y==0)return x;
  else return gcd(y,x%y);
}
int main(){
  ll n;
  cin>>n;
  vector<ll> p(m+1);
  for(int i=1;i<=m;i++){
    p[i]=(1LL<<i)-1;
    
  }
  ll t=p[n+1];
  for(int i=n;i>0;i--){
    t/=gcd(t,p[i]);
  }
  
  if(t==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  
}
0