結果
| 問題 |
No.1325 Subsequence Score
|
| コンテスト | |
| ユーザー |
_____TAB_____
|
| 提出日時 | 2020-12-04 16:28:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 195 ms / 2,000 ms |
| コード長 | 1,883 bytes |
| コンパイル時間 | 501 ms |
| コンパイル使用メモリ | 67,096 KB |
| 最終ジャッジ日時 | 2025-01-16 15:53:47 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#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/2;
for(int i = 0; i < n; ++i){
long long a;
cin >> a;
ans += t*(i+2)*a;
}
cout << ans << endl;
}
_____TAB_____