結果
問題 | No.1529 Constant Lcm |
ユーザー | oliverx3 |
提出日時 | 2021-06-04 21:37:48 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 7,194 bytes |
コンパイル時間 | 4,673 ms |
コンパイル使用メモリ | 270,432 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-19 13:11:27 |
合計ジャッジ時間 | 7,978 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,820 KB |
testcase_01 | AC | 4 ms
6,820 KB |
testcase_02 | AC | 3 ms
6,820 KB |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 3 ms
6,816 KB |
testcase_05 | AC | 3 ms
6,816 KB |
testcase_06 | AC | 3 ms
6,816 KB |
testcase_07 | AC | 3 ms
6,816 KB |
testcase_08 | AC | 3 ms
6,816 KB |
testcase_09 | AC | 3 ms
6,820 KB |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | AC | 18 ms
6,816 KB |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
ソースコード
/** * author: oliverx3 * created: 04.06.2021 21:16:37 **/ #include <bits/stdc++.h> #if __has_include(<atcoder/all>) #include <atcoder/all> #endif #pragma region header #pragma region alias using lint = long long; using ll = long long; using P = std::pair<int,int>; template<class T> using prique = std::priority_queue<T,std::vector<T>,std::greater<T>>; #pragma endregion #pragma region macros #define rep(i, n) for(int i = 0;i<(int)(n);i++) #define REP(i, m, n) for(int i = (m);i<(int)(n);i++) #define drep(i, n) for(int i = (n)-1;i>=0;i--) #define DREP(i, m, n) for(int i = (m)-1;i>=(int)(n);i--) #define all(v) (v).begin(),(v).end() #define reall(v) (v).rbegin(),(v).rend() template<class T, class U> bool chmax(T& a,const U b) { if(a < b) { a = b; return true; } return false; } template<class T, class U> bool chmin(T& a,const U b) { if(a>b) { a = b; return true; } return false; } bool is_flag(const long long &bit, const int &k) { return (bit >> k)&1; } #pragma endregion #pragma region constant constexpr int inf = 1<<30; constexpr long long INF = 1LL << 61; constexpr long double eps = 1e-10; constexpr long double pi = 3.141592653589793238; constexpr int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; constexpr int dy[9] = {0, 1, 0, -1, 1, -1, 1, -1, 0}; constexpr long long mod = 1e9+7; constexpr long long MOD = 998244353; #pragma endregion #pragma region inout template<class T> std::ostream& operator<<(std::ostream& stream, const std::vector<T>& v) { for(int i = 0; i < (int)(v.size()); i++) { stream << v[i]; if(i != (int)(v.size()) - 1) stream << ' '; } return stream; } template<typename Itr> inline void print(const Itr& begin, const Itr& end, bool endline = true, const char* BEGIN = "{", const char* mid = ", ", const char* END = "}") { if(begin == end) return; std::cout << BEGIN << *begin; for(Itr itr = begin+1; itr < end; itr++) std::cout << mid << *itr; std::cout << END; if(endline) std::endl(std::cout); return; } template<class T> std::istream& operator>>(std::istream& stream, std::vector<T>& v) { for(T& p:v) stream >> p; return stream; } template<typename Itr> inline void input(Itr begin, Itr end) { for(Itr& itr = begin; itr < end; itr++) std::cin >> *itr; return; } template<class T, class U> std::ostream& operator<<(std::ostream& stream, const std::pair<T,U>& pair) { return stream << pair.first << ' ' << pair.second; } template<class T, class U> inline void print(const std::pair<T,U>& pair,const bool endline = true, const char* begin = "(", const char* mid = ", ", const char* end = ")") { std::cout << begin << pair.first << mid << pair.second << end; if(endline) std::endl(std::cout); else std::cout << ' '; return; } template<class T, class U> std::istream& operator>>(std::istream& stream, std::pair<T,U>& pair) { return stream >> pair.first >> pair.second; } template<class T, class U> inline void input(std::pair<T,U>& pair, const bool first = true, const bool second = true) { if(first) std::cin >> pair.first; if(second) std::cin >> pair.second; } #pragma endregion #pragma region DEBUG #ifdef _DEBUG template<class T> inline void _debug_view(const T& x) noexcept { std::cout << x; return; } template<class T, class U> inline void _debug_view(const std::pair<T,U>& p) noexcept { std::cout << "("; _debug_view(p.first); std::cout << ", "; _debug_view(p.second); std::cout << ")"; return; } template<class T> inline void _debug_view(const std::vector<T>& v) noexcept { std::cout << "{"; for(int i = 0;i<v.size();i++) { _debug_view(v[i]); std::cout << (i+1 == v.size() ? "" : ", "); } std::cout << "}"; return; } template<class T, class U> inline void _debug_view(const std::map<T,U>& mp) noexcept { std::cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) { _debug_view(*itr); if(std::next(itr) != mp.end()) std::cout << ", "; } std::cout << "}"; return; } template<class T> inline void _debug_view(const std::set<T>& st) noexcept { std::cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) { _debug_view(*itr); if(std::next(itr) != st.end()) std::cout << ", "; } std::cout << "}"; return; } #define overload5(_1,_2,_3,_4,_5,name,...) name #define _debug1(a) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::endl(std::cout);\ }while(0);\ } #define _debug2(a,b) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::endl(std::cout);\ }while(0);\ } #define _debug3(a,b,c) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::cout << ", " << #c << ": ";\ _debug_view(c);\ std::endl(std::cout);\ }while(0);\ } #define _debug4(a,b,c,d) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::cout << ", " << #c << ": ";\ _debug_view(c);\ std::cout << ", " << #d << ": ";\ _debug_view(d);\ std::endl(std::cout);\ }while(0);\ } #define _debug5(a,b,c,d,e) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::cout << ", " << #c << ": ";\ _debug_view(c);\ std::cout << ", " << #d << ": ";\ _debug_view(d);\ std::cout << ", " << #e << ": ";\ _debug_view(e);\ std::endl(std::cout);\ }while(0);\ } #define debug(...) overload5(__VA_ARGS__,_debug5,_debug4,_debug3,_debug2,_debug1,)(__VA_ARGS__) #else #define debug(...) #endif #pragma endregion #pragma endregion using mint = atcoder::modint998244353; long long mod_pow(long long n, long long k, const long long mod_ = 998244353) { long long res = 1; while(k) { if(k&1) { res*=n; res%=mod_; } n*=n; n%=mod_; k>>=1; } return res; } int sieve[100010]; std::map<int, int> fast_prime_fact(int n) { std::map<int, int> res; while(sieve[n] != -1) { res[sieve[n]]++; n /= sieve[n]; } return res; } int main() { sieve[1] = -1; for(int i = 2; i <= 100005; i++) { if(sieve[i] != 0) continue; sieve[i] = i; for(int j = i*2; j <= 100005; j+=i) { sieve[j] = i; } } int n; std::cin >> n; std::map<int, int> mp; for(int i = 1; i <= n-1; i++) { std::map<int, int> fac; for(const auto &p:fast_prime_fact(i)) fac[p.first] += p.second; for(const auto &p:fast_prime_fact(n-i)) fac[p.first] += p.second; for(const auto &p:fac) chmax(mp[p.first], p.second); } mint ans = 1; for(const auto &p:mp) ans *= mod_pow(p.first, p.second); std::cout << ans.val() << std::endl; return 0; }