fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. struct app{
  4. int num;
  5. int index;
  6. };
  7. bool compare(const app& a, const app& b) {
  8. return a.num< b.num;
  9. }
  10.  
  11. int main(){
  12. int t;
  13. cin>>t;
  14. while(t--) {
  15. int n,k;
  16. cin>>n>>k;
  17. app A[n];
  18. for (int i = 0; i < n; i++){
  19. cin >> A[i].num;
  20. A[i].index=i;
  21. }
  22. for(int i=0;i<n;i++){
  23. A[i].num=(A[i].num)%k;
  24.  
  25. }
  26. sort(A,A+n,compare);
  27. k++;
  28. for(int i=0;i<n;i++)
  29. cout<<A[i].index+1<<" ";
  30. cout<<"\n";
  31. }
  32. }
Success #stdin #stdout 0.01s 5428KB
stdin
Standard input is empty
stdout
Standard output is empty