比较简单的一道题目,直接枚举计算得出最后结果即可,具体实现见如下代码:
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<deque>
#include<functional>
using namespace std;
const int maxn = 205;
int data[maxn];
int T;
void solve(){
for (int a = 1; a < 10001; a++){
for (int b = 1; b < 10001; b++){
bool ok = true;
for (int i = 2; i <= 2 * T; i++){
int t = (data[i - 1] * a + b) % 10001;
if (i % 2){
if (t != data[i]){
ok = false;
break;
}
}
else{
data[i] = t;
}
}
if (ok) return;
}
}
}
int main(){
while (cin >> T){
for (int i = 1; i <= 2 * T; i += 2){
cin >> data[i];
}
solve();
for (int i = 2; i <= 2 * T; i += 2) cout << data[i] << endl;
}
return 0;
}