Educational Codeforces Round 47 (Rated for Div. 2) :E. Intercity Travelling

Posted goldenfingers

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Educational Codeforces Round 47 (Rated for Div. 2) :E. Intercity Travelling相关的知识,希望对你有一定的参考价值。

题目链接:http://codeforces.com/contest/1009/problem/E

 

解题心得:

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6+100;
const long long MOD = 998244353;
typedef long long ll;
ll num[maxn], pow2[maxn];
ll n;

void get_pow2(){
    pow2[0] = 1;
    for(int i=1;i<=n;i++)
        pow2[i] = (pow2[i-1] * 2) % MOD;
}


void init() {
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++) {
        scanf("%lld",&num[i]);
    }
    get_pow2();
}

void solve(){
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        ll temp;
        if(i == n)
            temp = 1;
        else
            temp = pow2[n-i] + pow2[n-i-1]*(n-i);
        temp %= MOD;
        ans += temp*num[i];
        ans %= MOD;
    }
    printf("%lld
",ans);
}

int main() {
    init();
    solve();
    return 0;
}

 

以上是关于Educational Codeforces Round 47 (Rated for Div. 2) :E. Intercity Travelling的主要内容,如果未能解决你的问题,请参考以下文章

Educational Codeforces Round 7 A

Educational Codeforces Round 7

Educational Codeforces Round 90

Educational Codeforces Round 33

Codeforces Educational Codeforces Round 54 题解

Educational Codeforces Round 27