結果

問題 No.2782 メルセンヌ数総乗
ユーザー Ponzu
提出日時 2024-06-14 21:56:13
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 3,075 ms
コンパイル使用メモリ 244,888 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-14 21:56:21
合計ジャッジ時間 3,835 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#include<atcoder/all>
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0;i<(n);++i)
long long powll(long long a, long long x){
	if(x==0) return 1LL;
	long long ret = 1LL;
	while(x>0) {
		if(x&1) ret *= a;
		a *= a;
		x >>= 1;
	}
	return ret;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n;
	cin >> n;
	ll res = 1;
	ll mod = powll(2LL,(n+1)) - 1;
	for(ll i=2;i<=n;++i){
		res*=powll(2LL,i)-1;
		res%=mod;
	}

	if(res==0)cout << "Yes" << endl;
	else cout << "No" << endl;
	
}
0