結果

問題 No.3133 法B逆元
ユーザー t98slider
提出日時 2025-05-03 20:30:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 423 bytes
コンパイル時間 2,723 ms
コンパイル使用メモリ 191,284 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-05-03 20:30:34
合計ジャッジ時間 3,326 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    unsigned long long n, b;
    cin >> n >> b;
    if(b == 1){
        cout << "0\n";
        return 0;
    }
    const unsigned int d = n % b;
    unsigned int v = 0;
    for(unsigned int i = 1; i < b; i++){
        v += d;
        if(v >= b) v -= b;
        if(v == 1){
            cout << i << '\n';
            return 0;
        }
    }
    cout << "NaN\n";
}
0