結果
| 問題 | 
                            No.1325 Subsequence Score
                             | 
                    
| コンテスト | |
| ユーザー | 
                             _____TAB_____
                         | 
                    
| 提出日時 | 2020-12-04 16:38:55 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 55 ms / 2,000 ms | 
| コード長 | 1,963 bytes | 
| コンパイル時間 | 499 ms | 
| コンパイル使用メモリ | 72,408 KB | 
| 最終ジャッジ日時 | 2025-01-16 15:54:07 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 28 | 
ソースコード
#include <iostream>
#include <iomanip>
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(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  using mint = modint<998244353>;
  int n;
  cin >> n;
  
  mint ans = 0, t = power<mint>(2,n)/2/2;
  
  for(int i = 0; i < n; ++i){
    long long a;
    cin >> a;
    ans += (i+2)*a;
  }
  ans *= t;
  cout << ans << endl;
}
            
            
            
        
            
_____TAB_____