結果
| 問題 |
No.1232 2^x = x
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-18 22:23:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 388 bytes |
| コンパイル時間 | 2,249 ms |
| コンパイル使用メモリ | 192,076 KB |
| 最終ジャッジ日時 | 2025-01-14 17:24:36 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
#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");
}
}