結果

問題 No.1325 Subsequence Score
ユーザー _____TAB__________TAB_____
提出日時 2020-12-04 16:15:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,879 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 68,536 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 16:36:25
合計ジャッジ時間 3,899 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 180 ms
4,348 KB
testcase_14 AC 53 ms
4,348 KB
testcase_15 AC 151 ms
4,348 KB
testcase_16 AC 170 ms
4,348 KB
testcase_17 AC 80 ms
4,348 KB
testcase_18 AC 46 ms
4,348 KB
testcase_19 AC 187 ms
4,348 KB
testcase_20 AC 26 ms
4,348 KB
testcase_21 AC 63 ms
4,348 KB
testcase_22 AC 76 ms
4,348 KB
testcase_23 AC 183 ms
4,348 KB
testcase_24 AC 176 ms
4,348 KB
testcase_25 AC 180 ms
4,348 KB
testcase_26 AC 185 ms
4,348 KB
testcase_27 AC 186 ms
4,348 KB
testcase_28 WA -
testcase_29 AC 2 ms
4,348 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a((x%mod+mod)%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend std::ostream& operator<<(std::ostream &os, const modint &X){
    return os << X.a;
  }
  friend std::istream& operator>>(std::istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

template<typename T>
T power(T x, long long k){
  T ret{1};
  while(k > 0){
    if(k&1) ret *= x;
    x *= x;
    k /= 2;
  }
  return ret;
}

int main(){
  using mint = modint<998244353>;

  int n;
  cin >> n;
  
  mint ans = 0, t = power<mint>(2,n-2);

  for(int i = 0; i < n; ++i){
    long long a;
    cin >> a;
    ans += t*(i+2)*a;
  }
  
  cout << ans << endl;
}
0