You are given two integers n and k.    You ought to make a variety of n positive integers a1,a2,… ,a to such an extent that the total (a1+a2+⋯+an) is distinguishable by k and greatest component in an is least conceivable.    What is the base conceivable most extreme component in a?

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question

Correct answer will be upvoted else downvoted. Computer science.

 

 You are given two integers n and k. 

 

You ought to make a variety of n positive integers a1,a2,… ,a to such an extent that the total (a1+a2+⋯+an) is distinguishable by k and greatest component in an is least conceivable. 

 

What is the base conceivable most extreme component in a? 

 

Input 

 

The primary line contains a solitary integer t (1≤t≤1000) — the number of experiments. 

 

The solitary line of each experiment contains two integers n and k (1≤n≤109; 1≤k≤109). 

 

Output 

 

For each experiment, print one integer — the base conceivable most extreme component in cluster a to such an extent that the aggregate (a1+⋯+an) is distinct by k.

 

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Representation of Polynomial
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning