結果
| 問題 |
No.251 大きな桁の復習問題(1)
|
| コンテスト | |
| ユーザー |
minato
|
| 提出日時 | 2020-08-27 21:52:17 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 5,000 ms |
| コード長 | 2,084 bytes |
| コンパイル時間 | 19,385 ms |
| コンパイル使用メモリ | 294,380 KB |
| 最終ジャッジ日時 | 2025-01-13 15:31:37 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
inline int topbit(int x) {return x == 0 ? -1 : 31-__builtin_clz(x);}
inline int topbit(long long x) {return x == 0 ? -1 : 63-__builtin_clzll(x);}
inline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);}
inline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() {cout << "\n";}
template<class T, class... Args>
void print(const T &x, const Args &... args) {
cout << x << " ";
print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
constexpr ll mod = 129402307;
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
string S,T; cin >> S >> T;
int N = S.size();
int M = T.size();
ll n = 0;
rep(i,N) {
n = (n*10 + S[i] - '0')%mod;
}
if (n==0) {
if (T=="0") {
cout << 1 << ln;
} else {
cout << 0 << ln;
}
return 0;
}
ll m = 0;
rep(i,M) {
m = (m*10 + T[i] - '0')%(mod-1);
}
ll ans = 1, b = n;
while (m) {
if (m&1) {
ans = ans*b%mod;
}
b = b*b%mod;
m >>= 1;
}
cout << ans << ln;
}
minato