fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int N;
  9. cin >> N;
  10.  
  11.  
  12. for(; N-- > 0;)
  13. {
  14. int L, sB = 0, sC = 0;
  15. string O;
  16. cin >> L;
  17. int A[L], B[L], C[L];
  18. for(int i = 0; i < L; i++)
  19. cin >> A[i];
  20. for(int i = 0; i < L; i++)
  21. cin >> B[i];
  22.  
  23. cin >> O;
  24.  
  25. int j = 0;
  26. while(O[++j] != '1');
  27. sB = j - 1;//B shift 位數
  28. while(O[++j] != '1');
  29. sC = j - sB - 2;//C shift 位數
  30.  
  31. for(int i = 0; i < L; i++)
  32. C[(i + sC) % L] = A[i] + B[(i + sB) % L];
  33. for(int i = 0; i < L; i++)
  34. cout << C[i] << " ";
  35. cout << "\n";
  36.  
  37. }
  38.  
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
Standard output is empty