結果
| 問題 | No.1232 2^x = x |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-18 22:23:42 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 388 bytes |
| 記録 | |
| コンパイル時間 | 1,309 ms |
| コンパイル使用メモリ | 208,092 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-13 21:22:40 |
| 合計ジャッジ時間 | 2,441 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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");
}
}