杭电新生赛(1005)
#include<iostream> #include<cmath> long long w = 1e9 + 7; using namespace std; int main() { int n; while (cin >> n) { long long a[102]; for (int i = 1; i <= n+1; i++) cin >> a[i]; long long t = 1; for (int i = 1; i < n; i++) t = t * 2%w; long long s = 0; for (int i = 1; i <= n; i++) { s =( s + a[i] * t)%w; } s = (s + a[n+1]) % w; cout << s << endl; } return 0; }找规律。