显示原始代码
#include <bits/stdc++.h>
using namespace std;
long mod = 95041567;
queue<long long> q;
int t;
long long n, b[15], B[15], num[15];
bool cmp(int x, int y) {
if (b[x] == b[y])
return x < y;
return b[x] < b[y];
}
void countB(long long cur, long long tar, int pos) {
for (long long i = cur; i < tar; i++) {
long long begin = q.back();
q.push(begin);
while (q.front() != begin) {
q.push(q.back() + q.front());
q.pop();
}
q.push(q.back() + q.front());
q.pop();
}
B[pos] = q.back() % mod;
}
int main() {
scanf("%d", &t);
q.push(1);
for (int i = 1; i <= t; i++) {
scanf("%lld", &b[i]);
num[i] = i;
}
b[0] = 1;
sort(num + 1, num + t + 1, cmp);
for (int i = 1; i <= t; i++) countB(b[num[i - 1]], b[num[i]], num[i]);
sort(num + 1, num + t + 1);
for (int i = 1; i <= t; i++) cout << B[num[i]] << endl;
return 0;
}