結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
![]() |
提出日時 | 2014-10-08 01:06:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,847 bytes |
コンパイル時間 | 964 ms |
コンパイル使用メモリ | 91,896 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-30 08:04:26 |
合計ジャッジ時間 | 2,196 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 WA * 11 |
ソースコード
#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; }