#include <bits/stdc++.h>
using namespace std;
void fastIO() {
ios_base::sync_with_stdio(false), cin.tie(0);
}
#define int long long
const int MOD = 1e9 + 7;
const int MAXN = 10001;
int N;
int vals[MAXN];
int ans = 0;
long long modular(long long base, long long exp, int mod) {
long long res = 1;
while (exp > 0) {
if (exp % 2 == 1)
res= (res * base) % mod;
exp = exp >> 1;
base = (base * base) % mod;
}
return res;
}
signed main() {
fastIO();
cin >> N;
for (int i = 0; i < N; i++) {
cin >> vals[i];
}
reverse(vals, vals + N);
for (int i = 0; i < N; i++) {
ans += ((vals[i] - 1) * modular(N, i, MOD)) % MOD;
ans %= MOD;
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |