I went through the following code :
#include <stdio.h>
#define N 10000000
int main() {
static int rot[N], dd[N], qu[N];
int a, t, i, j, p, head, cnt;
scanf("%d%d", &a, &t);
for (i = 0, p = 1; i < N; i++) {
while (p * 10 <= i)
p *= 10;
rot[i] = i % 10 == 0 ? -1 : (i % 10) * p + i / 10;
}
for (i = 0; i < N; i++)
dd[i] = N;
head = cnt = 0;
dd[1] = 0, qu[head + cnt++] = 1;
while (cnt) {
int d;
i = qu[cnt--, head++], d = dd[i] + 1;
if (i == t) {
printf("%d\n", dd[i]);
return 0;
}
if ((long long) i * a < N) {
j = i * a;
if (dd[j] > d)
dd[j] = d, qu[head + cnt++] = j;
}
if (rot[i] != -1) {
j = rot[i];
if (dd[j] > d)
dd[j] = d, qu[head + cnt++] = j;
}
}
printf("-1\n");
return 0;
}
As one can see, qu is a static int array, i want to know what "i = qu[cnt--, head++]," line does, how are we passing two arguments to the index of array.