fork download
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. #define pb emplace_back
  4. #define mp make_pair
  5. #define x first
  6. #define y second
  7. #define all(a) a.begin(), a.end()
  8. #define rall(a) a.rbegin(), a.rend()
  9. typedef long double ld;
  10. typedef long long ll;
  11. using namespace std;
  12. mt19937 rnd(time(nullptr));
  13.  
  14. signed main()
  15. {
  16. ios_base::sync_with_stdio(false);
  17. cin.tie(nullptr);
  18. cout.tie(nullptr);
  19. int t; cin >> t;
  20. while (t--)
  21. {
  22. int n ; cin >> n;
  23. int k; cin >> k;
  24. vector<int> v(n);
  25. for (int i = 0; i < n; i++)
  26. {
  27. int x; cin >> x;
  28. v[i] = x%k;
  29. }
  30. // 2 2 0 2
  31. int x = 0;
  32. while (x < k)
  33. {
  34. for (int i = 0; i < n; i++)
  35. {
  36. if(v[i] == x){
  37. cout << i+1 << " ";
  38. }
  39. }
  40. x++;
  41. }
  42.  
  43. cout << endl;
  44. }
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0.01s 5312KB
stdin
3
3 2
1 2 3
2 3
1 1
4 3
2 8 3 5
stdout
2 1 3 
1 2 
3 1 2 4