fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define M INT_MIN
  4. int main(){
  5. int t;
  6. cin>>t;
  7. while(t--){
  8. int n;
  9. cin>>n;
  10. int a,b,c,d1=0,d2=0,test=M;
  11. cin>>b;
  12. for(int i=0;i<n-1;i++){
  13. cin>>c;
  14. d2=c-b;
  15. if(i!=0){
  16. if(d2==d1){
  17. if(test!=M){cout<<a-d1<<" ";test=M;}
  18. cout<<a<<" ";
  19. }
  20. else{
  21. if(test!=M){
  22. if(d2+d1==2*test)
  23. {b=(c+a)/2;cout<<a-test<<" "<<a<<" ";test=M;}
  24. else{cout<<b-2*d2<<" "<<b-d2<<" ";test=M;}
  25. }
  26. else test=d1;
  27. }
  28.  
  29. }
  30. a=b;
  31. b=c;
  32. d1=d2;
  33.  
  34. }
  35. if(test!=M)cout<<a-test<<" ";
  36. cout<<a<<" ";
  37. if(test==M)cout<<b<<endl;
  38. else cout<<a+test<<" "<<endl;
  39.  
  40. }
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 15240KB
stdin
5
5
9 1 1 1 1
4
2 1 1 1
4
1 3 6 7
stdout
1 1 1 1 1
1 1 1 1
1 3 5 7
7 7 7 7
7 7 7 7