priyansh_max's blog

By priyansh_max, history, 3 days ago, In English

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 :)

  • Vote: I like it
  • -5
  • Vote: I do not like it

»
3 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by priyansh_max (previous revision, new revision, compare).