解法一:暴力枚举:
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=10005;
const int mod=10001;
int T,x[maxn];
int main()
{
std::ios::sync_with_stdio(false);
// #ifndef ONLINE_JUDGE
// freopen("in.txt", "r", stdin);
// #endif
cin>>T;
for(int i=1 ; i<2*T ; i+=2)cin>>x[i];
int a,b,ok;
for(a=0 ; a<=10000 ; a++){
for(b=0 ; b<=10000 ; b++){
ok=1;
for(int i=2 ; i<=2*T ; i++){
if(i&1){
if(x[i]!=((a*x[i-1]+b)%mod)){
ok=0;
break;
}
}else{
x[i]=(a*x[i-1]+b)%mod;
}
}
if(ok)break;
}
if(ok)break;
}
for(int i=2 ; i<=2*T ;i+=2)cout<<x[i]<<endl;
return 0;
}
注:可能由于后台数据的原因,这道题直接暴力枚举a,b进行判断也能过,原题时间限制3s,暴力的代码也只用了0.4s。