Polynomial You are given and integer M, and 4M integers, a1, a2, ..., aM, b1, b2, ..., bM, c1, c2, ..., cM, and N1, N2, ..., NM. For each ai, bi, ci, Ni where i is integer from 1 to M, you have to output the maximum integer X such that aiX3 + biX2 + ciX <= Ni. Format Input The first line consist of an integer M. The second line consist of M integers, a1, a2, ..., aM. The third line consist of M integers, b1, b2, ..., bM. The fourth line consist of M integers, c1, c2, ..., cM. The fifth line consist of M integers, N1, N2, ..., NM. Format Output Output M lines. The i − th line consist of an integer which is the maximum integer X such that aiX3 + biX2 + ciX <= Ni Constraints • 1 ≤ M ≤ 105 • 1 ≤ ai, ci ≤ 5 • 1 ≤ bi ≤ 107 • 1 ≤ Ni ≤ 1015 Sample Input 1 (standard input) 2 1 2 2 1 3 2 100 60 Sample Output 1 (standard output) 3 2 Use C programming language.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
icon
Concept explainers
Question

Polynomial
You are given and integer M, and 4M integers, a1, a2, ..., aM, b1, b2, ..., bM, c1, c2, ..., cM, and N1, N2, ..., NM. For each ai, bi, ci, Ni where i is integer from 1 to M, you have to output the maximum integer X such that aiX3 + biX2 + ciX <= Ni.
Format Input
The first line consist of an integer M. The second line consist of M integers, a1, a2, ..., aM. The third line consist of M integers, b1, b2, ..., bM. The fourth line consist of M integers, c1, c2, ..., cM. The fifth line consist of M integers, N1, N2, ..., NM.
Format Output
Output M lines. The i − th line consist of an integer which is the maximum integer X such that aiX3 + biX2 + ciX <= Ni

Constraints
• 1 ≤ M ≤ 105
• 1 ≤ ai, ci ≤ 5
• 1 ≤ bi ≤ 107
• 1 ≤ Ni ≤ 1015
Sample Input 1 (standard input)
2
1 2
2 1
3 2
100 60
Sample Output 1 (standard output)
3
2

Use C programming language.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Control Structure
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