結果

問題 No.36 素数が嫌い!
ユーザー diginatudiginatu
提出日時 2014-10-08 01:06:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,847 bytes
コンパイル時間 1,319 ms
コンパイル使用メモリ 90,232 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-28 20:29:00
合計ジャッジ時間 2,006 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <climits>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <functional>
#include <map>
#include <memory>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <bitset>
#include <list>
#include <numeric>

using namespace std;

#include <typeinfo>

typedef long long LL;

LL MOD;
class mod{
	int n;

	public:
	mod(){ n = 0; }
	mod(long long no){ if(no<0)no=(MOD+no)%MOD; n=no%MOD; }
	operator int(){ return n; }
	mod operator = (long long no){if(no<0)no=MOD+no%MOD; n=no%MOD; return mod(n);}
	template <class T> mod operator % (T nx){return mod(this->n % nx);}
	template <class T> mod operator %= (T nx){*this=*this%nx; return *this;}
	template <class T> mod operator * (T nx){return mod( (long long)this->n * mod(nx));}
	template <class T> mod operator *= (T nx){*this=*this*nx; return *this;}
	template <class T> mod operator + (T nx){return mod( (long long)this->n + mod(nx) );}
	template <class T> mod operator += (T nx){*this=*this+nx; return *this;}
	template <class T> mod operator - (T nx){return mod((long long)this->n-mod(nx)+MOD);}
	template <class T> mod operator -= (T nx){*this=*this-nx; return *this;}
	mod pow(long long m, long long a = -1){ 
		if (a==-1) a = n;
		long long b = m, r = 1;
		while(b!=0){ if(b & 1) r *= a; r %= MOD; a *= a; a %= MOD; b >>= 1; }
		return mod(r);
	}
};

bool is_like(LL p) {
  if (p <= 2) {
    return false;
  }

  if (p%2 == 0) {
    return true;
  }

  return mod(2).pow(p-1) != 1;
}

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

  MOD = N;

	cout << (is_like(N)?"YES":"NO") << endl;

	return 0;
}
0