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
解题心得:
- 一个比较简单的组合数学,还需要找一些规律,自己把方向想得差不多了但是硬是找不到规律,还是看了大佬博客才知道的规律。这个题要预先处理2的n次方,不然快速幂也会TLE。
- 推荐两个大佬的博客:
- https://blog.csdn.net/u010746456/article/details/81057082
- https://blog.csdn.net/hyp1231/article/details/81061186
#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