algo — C++23 日本語リファレンス GitHub

test/yukicoder/1097.test.cpp

AC · 最終更新 2026-09-07 · GitHub

問題: https://yukicoder.me/problems/no/1097

依存するヘッダ(2)
実装
// competitive-verifier: PROBLEM https://yukicoder.me/problems/no/1097
#include <cstdint>
#include <iostream>
#include <vector>
#include "algorithm/doubling.hpp"
#include "segtree/monoid.hpp"

int main(void) {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;
    std::vector<int> to(n);
    for (int i = 0; i < n; ++i) to[i] = (i + a[i]) % n;
    Doubling<40, Add<std::int64_t>> db(to, a);
    int q;
    std::cin >> q;
    while (q--) {
        std::int64_t k;
        std::cin >> k;
        std::cout << db.jump(0, k).second << '\n';
    }

    return 0;
}