結果
問題 | No.2007 Arbitrary Mod (Easy) |
ユーザー | 🍮かんプリン |
提出日時 | 2022-07-15 23:19:32 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,738 bytes |
コンパイル時間 | 1,428 ms |
コンパイル使用メモリ | 165,476 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 20:44:33 |
合計ジャッジ時間 | 4,896 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
ソースコード
#pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <vector> #include <algorithm> #include <cmath> #include <map> #include <set> #include <string> #include <bitset> #include <complex> #include <deque> #include <functional> #include <limits> #include <list> #include <numeric> #include <queue> #include <stack> #include <utility> #include <array> #include <random> #include <tuple> #include <unordered_map> #include <unordered_set> #include <assert.h> #include <chrono> #include <cstring> #include <memory> #include <unistd.h> using namespace std; typedef long long ll; #define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl // vector???��?��??��?��o???��?��??��?��???��?��??��?�� template < typename T > ostream& operator<<(ostream& os, vector< T >& v) { os << "{"; for (int i = 0; i < (int)v.size(); i++) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; } // pair???��?��??��?��o???��?��??��?��???��?��??��?�� template < typename T, typename U > ostream& operator<<(ostream& os, const pair< T, U >& p) { return os << "(" << p.first << ", " << p.second << ")"; } // map???��?��??��?��o???��?��??��?��???��?��??��?�� template < typename T, typename U > ostream& operator<<(ostream& os, const map< T, U >& map_var) { os << "{"; for (auto itr = map_var.begin(); itr != map_var.end(); itr++) { os << "(" << itr->first << ", " << itr->second << ")"; itr++; if (itr != map_var.end()) os << ", "; itr--; } os << "}"; return os; } // set ???��?��??��?��o???��?��??��?��???��?��??��?�� template < typename T > ostream& operator<<(ostream& os, const set< T >& set_var) { os << "{"; for (auto itr = set_var.begin(); itr != set_var.end(); itr++) { os << *itr; ++itr; if (itr != set_var.end()) os << ", "; itr--; } os << "}"; return os; } // multiset ???��?��??��?��o???��?��??��?��???��?��??��?�� template < typename T > ostream& operator<<(ostream& os, const multiset< T >& set_var) { os << "{"; for (auto itr = set_var.begin(); itr != set_var.end(); itr++) { os << *itr; ++itr; if (itr != set_var.end()) os << ", "; itr--; } os << "}"; return os; } #pragma endregion ///////////////////////////////////////// #include "bits/stdc++.h" using namespace std; typedef long long ll; template< int MOD > struct mint { public: unsigned int x; mint() : x(0) {} mint(long long v) { long long w = (long long)(v % (long long)(MOD)); if (w < 0) w += MOD; x = (unsigned int)(w); } mint(std::string &s) { unsigned int z = 0; for (int i = 0; i < s.size(); i++) { z *= 10; z += s[i] - '0'; z %= MOD; } x = z; } mint operator+() const { return *this; } mint operator-() const { return mint() - *this; } mint& operator+=(const mint &a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } mint& operator-=(const mint &a) { if ((x -= a.x) >= MOD) x += MOD; return *this; } mint& operator*=(const mint &a) { unsigned long long z = x; z *= a.x; x = (unsigned int)(z % MOD); return *this; } mint& operator/=(const mint &a) {return *this = *this * a.inv(); } friend mint operator+(const mint& lhs, const mint& rhs) { return mint(lhs) += rhs; } friend mint operator-(const mint& lhs, const mint& rhs) { return mint(lhs) -= rhs; } friend mint operator*(const mint& lhs, const mint& rhs) { return mint(lhs) *= rhs; } friend mint operator/(const mint& lhs, const mint& rhs) { return mint(lhs) /= rhs; } friend bool operator==(const mint& lhs, const mint& rhs) { return lhs.x == rhs.x; } friend bool operator!=(const mint& lhs, const mint& rhs) { return lhs.x != rhs.x; } friend std::ostream& operator<<(std::ostream &os, const mint &n) { return os << n.x; } friend std::istream &operator>>(std::istream &is, mint &n) { unsigned int x; is >> x; n = mint(x); return is; } mint inv() const { assert(x); return pow(MOD-2); } mint pow(long long n) const { assert(0 <= n); mint p = *this, r = 1; while (n) { if (n & 1) r *= p; p *= p; n >>= 1; } return r; } // 存在しない場合0を返す(二乗して確認). // O(log^2MOD) mint sqrt() const { if (this->x < 2) return *this; if (this->pow((MOD-1)>>1).x != 1) return mint(0); mint b = 1, one = 1; while (b.pow((MOD-1) >> 1) == 1) b += one; long long m = MOD-1, e = 0; while (m % 2 == 0) m >>= 1, e += 1; mint x = this->pow((m - 1) >> 1); mint y = (*this) * x * x; x *= (*this); mint z = b.pow(m); while (y.x != 1) { int j = 0; mint t = y; while (t != one) j += 1, t *= t; z = z.pow(1LL << (e-j-1)); x *= z; z *= z; y *= z; e = j; } return x; } }; constexpr int MOD = 1e9 + 7; int main() { int a;ll n;cin >> a >> n; cout << mint<MOD>(a).pow(n) << endl; return 0; } /////////////////////////////////////////