← Back to List

17827번: 달팽이 리스트 ↗

Solutions

C++14
433 B | 433 chars
#include <iostream>

using namespace std;
int N,M,V,input;
int C[1100000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N >> M >> V;
    V--;
    for(int x = 0; x<N; x++) cin>> C[x];
    for(int x = 0; x<M; x++) {
        cin >> input;
        if(input <= V) cout<<C[input]<<"\n";
        else {
            input -=V;
            cout<<C[V + (input % (N-V))]<<"\n";
        }


    }
}