結果

問題 No.2191 一元二次式 mod 奇素数
ユーザー lddlinan
提出日時 2023-03-16 02:07:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 587 ms
コンパイル使用メモリ 85,188 KB
最終ジャッジ日時 2025-02-11 11:49:42
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |     scanf("%d", &p);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;


int expit(LL b, int e, int m) {
    LL r=1;
    while(e) {
        if (e&1) { r*=b; r%=m; }
        b*=b; b%=m;
        e>>=1;
    }
    return r;

}
int main() {
    int n, i, p, v;
    scanf("%d", &p);
    v = expit(2, (p-1)/2, p);
    if (v==1) printf("YES\n"); else printf("NO\n");
    return 0;
}
0