Mutual Indivisibility

Sort by

recency

|

13 Discussions

|

  • + 1 comment
    int range = (b-a)+1;
                int limit = (range-x)+1;
                int[] arr = new int[x];
                int start=a;
                for(int i=0;i<limit;i++){
                    
                    int inside = start;
                    
                    for(int j=0;j<x;j++){
                        arr[j] = inside;
                        inside++;
                    }
                    int check = arr[0]*2;
                    if(arr[x-1]>=check && arr.length==range ){
                        int ans = -1;
                        System.out.print(ans);
                        break;
                    }else if(arr[x-1]<check){
                        for(int k=0;k<x;k++){ 
                            System.out.print(arr[k]+" ");
                        }
                    System.out.println("");
                    break;    
                    }
                        
                    start++;    
       
                    }
    

    Why set [3,4,5] is not accepted as avalid output when it was clearly mentioned it is also one of the valid output in explanation.

    image

    image

  • + 1 comment

    I didn't expect but following program works. -_-b

    #!/bin/python3
    
    import sys
    
    if __name__ == "__main__":
        t = int(input().strip())
        for a0 in range(t):
            a, b, x = input().strip().split(' ')
            a, b, x = [int(a), int(b), int(x)]
            # Write Your Code Here
            if b//(b-x+1) >= 2:
                print('-1')
            else:
                print(' '.join(map(str, range(b-x+1,b+1))))
    
  • + 0 comments

    After multiple attempts, got this working in java.

  • + 1 comment

    image

  • + 0 comments

    why this solution isnt valid (it gave me same out put as cases but the site give me time error )? t= int(input().strip()) l=[] for a0 in range(t): a, b, x = input().strip().split(' ') a, b, x = [int(a), int(b), int(x)] xx=list(range(int(a),int(b)+1)) n=int(x) xxx=list(reversed(xx)) for x0 in xxx : y=[x0] for x1 in xxx : for y0 in y: if x1 % y0 !=0 and y0 %x1 !=0 : z = 1 else: z=2 break if z ==1: y.append(x1) if len(y)== n: break if len(y)== n: l.append(y) break elif len(y) != n and xxx.index(x0) for l0 in l: if type(l0)==type([]): for x0 in l0: z.append(str(x0)) print(" ".join(z)) z.clear() else: print(l0)