結果
問題 | No.2729 Addition and Multiplication in yukicoder (Easy) |
ユーザー |
![]() |
提出日時 | 2024-05-26 16:45:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 165 ms / 2,000 ms |
コード長 | 1,952 bytes |
コンパイル時間 | 764 ms |
コンパイル使用メモリ | 78,916 KB |
最終ジャッジ日時 | 2025-02-21 16:47:26 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <iostream>#include <cassert>#include <vector>#include <algorithm>#include <utility>namespace kekenx {template<typename T, T mod>class ModInt {public:ModInt(T y): x(y >= 0? y % mod: (mod - (-y) % mod) % mod) {}T get() {return x;}ModInt &operator+=(const ModInt &p) {if ((x += p.x) >= mod) x -= mod;return *this;}ModInt &operator-=(const ModInt &p) {if ((x += mod - p.x) >= mod) x -= mod;return *this;}ModInt &operator*=(const ModInt &p) {x = x * p.x % mod;return *this;}ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}ModInt operator-() const { return ModInt(-x); }ModInt operator+(const ModInt &p) const {return ModInt(*this) += p; }ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p; }ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p; }ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p; }bool operator==(const ModInt &p) const { return x == p.x; }bool operator!=(const ModInt &p) const { return x != p.x; }ModInt pow(int e) const {T a = 1, p = x;while(e > 0) {if (e % 2 == 0) {p = (p * p) % mod;e /= 2;} else {a = (a * p) % mod;e--;}}return ModInt(a);}private:T x;ModInt inverse() const {T a = x, b = mod, u = 1, v = 0, t;while (b > 0) {t = a / b;a -= t * b;std::swap(a, b);u -= t * v;std::swap(u, v);}return ModInt(u);}};} // kekenxusing namespace std;using mint = kekenx::ModInt<long long, 998244353>;int main() {int N; cin >> N;vector<long long> A(N);for (long long &a: A) cin >> a;sort(A.begin(), A.end());mint x = 0;for (int i = 0; i < N; i++) {x = mint(10) * x + mint(A[i]);}cout << x.get() << endl;return 0;}