GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday 11 May 2022

Anti-knapsack CodeChef Solution | CodeChef Problem Solution 2022

You are given two integers N and K.

Construct an array A consisting of N distinct positive integers such that the following conditions are met:

  • 1Ai2104;
  • There exists no subsequence of A with sum K.
Solution Click Below:-  CLICK HERE

It can be shown that the answer always exists.

Input Format

  • The first line contains a single integer T: the number of test cases.
  • The only line of each test case contains two integers N and K - as mentioned in the statement.

Output Format

For each test case, print a single line containing N space-separated elements: A1,A2,,AN. If there are multiple answers, you may print any.

Constraints

  • 1T20
  • 1N1000
  • 1K106

Join Now for Solution:- 

No comments:

Post a Comment