結果
| 問題 |
No.1232 2^x = x
|
| コンテスト | |
| ユーザー |
w2w2
|
| 提出日時 | 2020-09-18 23:06:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,746 bytes |
| コンパイル時間 | 1,886 ms |
| コンパイル使用メモリ | 195,612 KB |
| 最終ジャッジ日時 | 2025-01-14 17:46:49 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using pll = pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")
template <class T>
inline void chmin(T& a, T b) {
if(a > b) { a= b; }
}
template <class T>
inline void chmax(T& a, T b) {
if(a < b) { a= b; }
}
/* modとる */
inline ll modu(ll a, ll b) { return (a % b + b) % b; }
/* 逆元(法mod = 1e9+7) */
ll modinv(ll a, ll b) {
ll c= b, u= 1, v= 0;
while(b) {
ll t= a / b;
a-= t * b;
swap(a, b);
u-= t * v;
swap(u, v);
}
return modu(u, c);
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(12);
ll N;
cin >> N;
vl P(N);
REP(i, N) cin >> P[i];
REP(i, N) {
if(P[i] != 2) {
cout << modinv(P[i] - 1, P[i]) * (P[i] - 1) << endl;
} else {
cout << 2 << "\n";
}
}
}
w2w2