結果

問題 No.1299 Random Array Score
ユーザー nok0nok0
提出日時 2020-11-06 09:34:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 2,967 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 202,096 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-22 15:03:14
合計ジャッジ時間 5,156 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 28 ms
5,376 KB
testcase_04 AC 28 ms
5,376 KB
testcase_05 AC 22 ms
5,376 KB
testcase_06 AC 19 ms
5,376 KB
testcase_07 AC 21 ms
5,376 KB
testcase_08 AC 28 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 11 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 18 ms
5,376 KB
testcase_13 AC 27 ms
5,376 KB
testcase_14 AC 19 ms
5,376 KB
testcase_15 AC 19 ms
5,376 KB
testcase_16 AC 20 ms
5,376 KB
testcase_17 AC 5 ms
5,376 KB
testcase_18 AC 13 ms
5,376 KB
testcase_19 AC 15 ms
5,376 KB
testcase_20 AC 9 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 19 ms
5,376 KB
testcase_24 AC 21 ms
5,376 KB
testcase_25 AC 19 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 7 ms
5,376 KB
testcase_28 AC 5 ms
5,376 KB
testcase_29 AC 7 ms
5,376 KB
testcase_30 AC 18 ms
5,376 KB
testcase_31 AC 7 ms
5,376 KB
testcase_32 AC 26 ms
5,376 KB
testcase_33 AC 29 ms
5,376 KB
testcase_34 AC 18 ms
5,376 KB
testcase_35 AC 29 ms
5,376 KB
testcase_36 AC 18 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

//ModInt
template <const int& mod>
struct ModInt {
private:
	int x;

public:
	ModInt() : x(0) {}

	ModInt(long long x_) {
		if((x = x_ % mod + mod) >= mod) x -= mod;
	}

	int val() const { return x; }

	static int get_mod() { return mod; }

	constexpr ModInt& operator+=(ModInt rhs) {
		if((x += rhs.x) >= mod) x -= mod;
		return *this;
	}

	constexpr ModInt& operator-=(ModInt rhs) {
		if((x -= rhs.x) < 0) x += mod;
		return *this;
	}

	constexpr ModInt& operator*=(ModInt rhs) {
		x = (unsigned long long)x * rhs.x % mod;
		return *this;
	}

	constexpr ModInt& operator/=(ModInt rhs) {
		x = (unsigned long long)x * rhs.inv().x % mod;
		return *this;
	}

	constexpr ModInt operator-() const noexcept { return -x < 0 ? mod - x : -x; }

	constexpr ModInt operator+(ModInt rhs) const noexcept { return ModInt(*this) += rhs; }

	constexpr ModInt operator-(ModInt rhs) const noexcept { return ModInt(*this) -= rhs; }

	constexpr ModInt operator*(ModInt rhs) const noexcept { return ModInt(*this) *= rhs; }

	constexpr ModInt operator/(ModInt rhs) const noexcept { return ModInt(*this) /= rhs; }

	constexpr ModInt& operator++() {
		*this += 1;
		return *this;
	}

	constexpr ModInt operator++(int) {
		*this += 1;
		return *this - 1;
	}

	constexpr ModInt& operator--() {
		*this -= 1;
		return *this;
	}

	constexpr ModInt operator--(int) {
		*this -= 1;
		return *this + 1;
	}

	bool operator==(ModInt rhs) const { return x == rhs.x; }

	bool operator!=(ModInt rhs) const { return x != rhs.x; }

	bool operator<=(ModInt rhs) const { return x <= rhs.x; }

	bool operator>=(ModInt rhs) const { return x >= rhs.x; }

	bool operator<(ModInt rhs) const { return x < rhs.x; }

	bool operator>(ModInt rhs) const { return x > rhs.x; }

	ModInt inv() {
		int a = x, b = mod, u = 1, v = 0, t;
		while(b > 0) {
			t = a / b;
			std::swap(a -= t * b, b);
			std::swap(u -= t * v, v);
		}
		return ModInt(u);
	}

	ModInt pow(long long n) const {
		ModInt ret(1), mul(x);
		while(n > 0) {
			if(n & 1) ret *= mul;
			mul *= mul;
			n >>= 1;
		}
		return ret;
	}

	ModInt sqrt() const {
		if(x <= 1) return x;
		int v = (mod - 1) / 2;
		if(pow(v) != 1) return -1;
		int q = mod - 1, m = 0;
		while(~q & 1) q >>= 1, m++;
		std::mt19937 mt;
		ModInt z = mt();
		while(z.pow(v) != mod - 1) z = mt();
		ModInt c = z.pow(q), t = pow(q), r = pow((q + 1) / 2);
		for(; m > 1; m--) {
			ModInt tmp = t.pow(1 << (m - 2));
			if(tmp != 1) r = r * c, t = t * c * c;
			c = c * c;
		}
		return std::min(r.x, mod - r.x);
	}

	friend std::ostream& operator<<(std::ostream& s, ModInt<mod> a) {
		s << a.x;
		return s;
	}

	friend std::istream& operator>>(std::istream& s, ModInt<mod>& a) {
		s >> a.x;
		return s;
	}
};
static int MOD = 998244353;
using mint = ModInt<MOD>;

mint res, two = 2;
int n, a;
long long k;
int main() {
	scanf("%d%lld", &n, &k);

	for(int i = 0; i < n; i++) {
		scanf("%d", &a);
		res += a;
	}

	res *= two.pow(k);

	std::cout << res << "\n";
}
0