/* -*- coding: utf-8 -*- * * 1013.cc: No.1013 〇マス進む - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; const int BN = 30; /* typedef */ typedef long long ll; /* global variables */ int ps[MAX_N], ts[MAX_N][BN], rs[MAX_N][BN]; /* subroutines */ /* main */ int main() { int n, k; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) scanf("%d", ps + i); for (int i = 0; i < n; i++) { int d = i + ps[i]; ts[i][0] = d % n; rs[i][0] = d / n; } for (int j = 0; j + 1 < BN; j++) for (int i = 0; i < n; i++) { ts[i][j + 1] = ts[ts[i][j]][j]; rs[i][j + 1] = rs[i][j] + rs[ts[i][j]][j]; } for (int i = 0; i < n; i++) { int u = i, r = 0; for (int j = 0, bj = 1; j < BN; j++, bj <<= 1) if (k & bj) { r += rs[u][j]; u = ts[u][j]; } printf("%lld\n", (ll)r * n + u + 1); } return 0; }