結果
問題 | No.1819 Mirrored 2 |
ユーザー | 👑 Nachia |
提出日時 | 2022-01-21 22:29:42 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,424 bytes |
コンパイル時間 | 551 ms |
コンパイル使用メモリ | 77,208 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-05-04 13:38:50 |
合計ジャッジ時間 | 4,192 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,752 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
ソースコード
#include <vector> #include <utility> namespace nachia{ template<unsigned int MOD> struct StaticModint{ private: using u64 = unsigned long long; unsigned int x; public: using my_type = StaticModint; StaticModint() : x(0){} StaticModint(unsigned int v) : x(v){} unsigned int operator*() const { return x; } my_type& operator+=(const my_type& r){ auto t = x + r.x; if(t >= MOD) t -= MOD; x = t; return *this; } my_type operator+(const my_type& r) const { my_type res = *this; return res += r; } my_type& operator-=(const my_type& r){ auto t = x + MOD - r.x; if(t >= MOD) t -= MOD; x = t; return *this; } my_type operator-(const my_type& r) const { my_type res = *this; return res -= r; } my_type operator-() const { my_type res = *this; res.x = ((res.x == 0) ? 0 : (MOD - res.x)); return res; } my_type& operator*=(const my_type& r){ x = (u64)x * r.x % MOD; return *this; } my_type operator*(const my_type& r) const { my_type res = *this; return res *= r; } my_type pow(unsigned long long i) const { my_type a = *this, res = 1; while(i){ if(i & 1) res *= a; a *= a; i >>= 1; } return res; } my_type inv() const { return pow(MOD-2); } unsigned int val() const { return x; } static unsigned int get_mod() { return MOD; } my_type& operator/=(const my_type& r){ return operator*=(r.inv()); } my_type operator/(const my_type& r) const { return operator*(r.inv()); } }; } namespace nachia{ template<unsigned int MOD> struct PrimitiveRoot{ static constexpr unsigned long long powm(unsigned long long a, unsigned long long i) { unsigned long long res = 1, aa = a; while(i){ if(i & 1) res = res * aa % MOD; aa = aa * aa % MOD; i /= 2; } return res; } static constexpr bool examine_val(unsigned int g){ unsigned int t = MOD - 1; for(unsigned long long d=2; d*d<=t; d++) if(t % d == 0){ if(powm(g, (MOD - 1) / d) == 1) return false; while(t % d == 0) t /= d; } if(t != 1) if(powm(g, (MOD - 1) / t) == 1) return false; return true; } static constexpr unsigned int get_val(){ for(unsigned int x=2; x<MOD; x++) if(examine_val(x)) return x; return 0; } static const unsigned int val = get_val(); }; } #include <iostream> #include <algorithm> using namespace std; using i64 = long long; using u64 = unsigned long long; using i32 = int; using u32 = unsigned int; #define rep(i,n) for(int i=0; i<(n); i++) using m32 = nachia::StaticModint<90007>; int main() { i64 P,Q,x,y; cin >> P >> Q >> x >> y; string rev_stry = to_string(y); reverse(rev_stry.begin(), rev_stry.end()); string rev_strQ = to_string(Q); reverse(rev_strQ.begin(), rev_strQ.end()); if(y % 10 == 0) y += Q; i64 rev_y = 0; for(auto a : rev_stry) rev_y = rev_y * 10 + a - '0'; i64 rev_Q = 0; for(auto a : rev_strQ) rev_Q = rev_Q * 10 + a - '0'; m32 r_ans = m32(10).pow(rev_strQ.size()) * rev_y; m32 off_ans = m32(rev_Q); int len_r_ans = 0; while((r_ans + off_ans).val() != x){ len_r_ans++; r_ans *= 10; } cout << rev_stry << string(len_r_ans, '0') << rev_strQ << "\n"; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;