結果
| 問題 | 
                            No.3133 法B逆元
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-06-26 20:03:43 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 12 ms / 2,000 ms | 
| コード長 | 915 bytes | 
| コンパイル時間 | 1,112 ms | 
| コンパイル使用メモリ | 105,468 KB | 
| 実行使用メモリ | 7,844 KB | 
| 最終ジャッジ日時 | 2025-06-26 20:03:46 | 
| 合計ジャッジ時間 | 1,970 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 21 | 
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<iomanip>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<limits.h>
#include<bit>
#include<bitset>
using namespace std;
#define rep(i, n) for (ull i = 0; i < (ull)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
#define infl LLONG_MAX
#define infi INT32_MAX
void de(ll n){cout << n << endl;}
typedef pair<ll, ll> P;
#define all(a) (a).begin(), (a).end()
void cincout(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout<< fixed << setprecision(15);
}
int main(){
    cincout();
    ull N, B;
    cin >> N >> B;
    N %= B;
    if(B == 1){
        cout << 0 << endl;
        return 0;
    }
    rep(i, B){
        if(N * (i + 1) % B == 1){
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << "NaN" << endl;
}