Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
182515365 Contestant:
OussamaJB
1758C - 17 C++14 (GCC 6-32) Wrong answer on pretest 2 15 ms 3924 KB 2022-11-25 19:33:11 2022-11-25 19:33:11
→ Source
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<int,int>
const int N=1e6+1;
int t,n,x,p[N];


int main(){
    ios_base::sync_with_stdio(false);
    cin >> t;
    while(t--){
        cin >> n >> x;
        if(n%x){
            cout << -1 << '\n';
        }else{
            for(int i=1;i<=n;++i) p[i]=i;
            if(x==n){
                swap(p[1],p[n]);
            }else{
                p[n]=1;
                p[1]=x;
                p[x]=n;
                int pos=x;
                for(int i=x+1;i<n;++i){
                    if(i%pos==0&&n%i==0){
                        swap(p[pos],p[i]);
                        pos=i;
                        break;
                    }
                }
            }
            for(int i=1;i<=n;++i) cout << p[i] << ' ';
            cout << '\n';
        }
    }
}

?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details