fork download
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. void troca(string &aux, int pos){
  8. if(aux[pos] == 'o'){
  9. aux[pos] = 'x';
  10. }else aux[pos] = 'o';
  11. }
  12.  
  13. int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b); }
  14.  
  15. int main(){
  16. ios::sync_with_stdio(false);
  17. int n, q;
  18. while((cin >> n >> q) && n){
  19. string lamp; cin >> lamp;
  20. for(int i = 0; i < q; i++){
  21. int k, m, pos = 0; cin >> k >> m;
  22. string aux = lamp;
  23. int div = m / n;
  24. int cont = n * div;
  25. if(gcd(n, k) == 1){
  26. if(div % 2 != 0){
  27. for(int i = 0; i < n; i++) troca(aux, i);
  28. }
  29. }
  30. while(cont < m){
  31. troca(aux, pos);
  32. pos = (pos + k)%n;
  33. cont++;
  34. }
  35. cout << aux << '\n';
  36. }
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty