码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-07-24 11:12:43      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:ret   type   init   ORC   void   nbsp   typedef   pre   rate   

题目链接: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\n",ans);
}

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

 

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

标签:ret   type   init   ORC   void   nbsp   typedef   pre   rate   

原文地址:https://www.cnblogs.com/GoldenFingers/p/9358719.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!