please help me debug

Revision en1, by priyansh_max, 2024-11-10 09:32:03

public static void main(String[] args) { FastReader sc = new FastReader();

int t = sc.nextInt();

    for (int i = 0; i < t; i++) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int ans = 0;
        int flag = 0;
        List<Integer> list = new ArrayList<>();
        if((n%2 == 1 && k == 2 && x == 1) || (k == 1 && x == 1)){
            flag = 1;
        }

        else{
            while(k > 0 && n > 0){
                if(k == x){
                    k--;
                }
                else{
                    ans += n/k;
                    int temp = n/k;
                    for(int j = 0; j < temp ; j++){
                        list.add(k);
                    }
                    n = n%k;
                    k--;
                }
            }
        }

        if(flag == 1){
            System.out.println("NO");
        }
        else{
            System.out.println("YES");
            System.out.println(ans);
            for(int j = 0 ; j < list.size() ; j++){
                System.out.print(list.get(j) + " ");
            }
            System.out.println("");
        }
    }
}

I am missing something here https://codeforces.net/contest/1845/problem/A

please suggest improvement as well :)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English priyansh_max 2024-11-10 09:33:02 37 Tiny change: 'ing here\nhttps://' -> 'ing here\nIt passes all the sample test cases\nhttps://'
en1 English priyansh_max 2024-11-10 09:32:03 1533 Initial revision (published)