結果
問題 | No.1232 2^x = x |
ユーザー | KKT89 |
提出日時 | 2020-09-18 22:23:42 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 388 bytes |
コンパイル時間 | 2,230 ms |
コンパイル使用メモリ | 199,448 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-22 09:57:02 |
合計ジャッジ時間 | 2,780 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll mod_inv(ll a,ll p){ ll b=p,x=1LL,y=0LL; while(b){ ll t=a/b; a-=t*b; swap(a,b); x-=t*y; swap(x,y); } return (x%p+p)%p; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; while(n--){ ll p; cin >> p; if(p!=2)printf("%lld\n",mod_inv(p-1,p)*(p-1)); else printf("2\n"); } }