Submission #1100860

# Submission time Handle Problem Language Result Execution time Memory
1100860 2024-10-14T20:22:52 Z vincentbucourt1 Rack (eJOI19_rack) C++14
0 / 100
1 ms 336 KB
#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";
}
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -