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 It passes all the sample test cases https://codeforces.net/contest/1845/problem/A
please suggest improvement as well :)
Auto comment: topic has been updated by priyansh_max (previous revision, new revision, compare).