Special Shop
Practice
3.8 (135 votes)
Algorithms
Easy
Searching
Differentiation
Problem
62% Success 48079 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Creatnx now wants to decorate his house by flower pots. He plans to buy exactly \(N\) ones. He can only buy them from Triracle's shop. There are only two kind of flower pots available in that shop. The shop is very strange. If you buy \(X\) flower pots of kind 1 then you must pay \(A\times X^2\) and \(B\times Y^2\) if you buy \(Y\) flower pots of kind 2. Please help Creatnx buys exactly \(N\) flower pots that minimizes money he pays.
Input Format
The first line contains a integer \(T\) denoting the number of test cases.
Each of test case is described in a single line containing three space-separated integers \(N, A, B\).
Output Format
For each test case, print a single line containing the answer.
Constraints
- \(1\le T \le 10^5\)
- \(1\le N, A, B \le 10^5\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
20 votes
Tags:
AlgorithmsLinear SearchSimulation
Points:30
102 votes
Tags:
EasySearching
Points:30
128 votes
Tags:
EasyPointerSearchingSets
Editorial