Internet Service Providers
Time limit1sMemory limit128 MB
Given N and C, find the smallest integer T minimizing/maximizing the quadratic profit N*T*(C-T*N), handling N=0 edge case.
- Level
Easy3 of 10
- Topics
- Math, Implementation, Binary search
- Solved
- No attempts yet
Problem
A group of Internet Service Provider companies (ISPs) share a private communication channel whose maximum capacity is traffic units per second. Every ISP pushes the same amount of traffic units per second through the channel, and each ISP earns a profit that is directly proportional to . The total profit of all ISPs is therefore proportional to .
Compute : the smallest integer value of that maximizes this total profit. Here , , , and are all integers.
When there are no ISPs (), the total profit is for every , and .
Input
The input contains several independent data sets and is read until end of file. Each data set has two integers and (), separated by whitespace: the number of ISPs and the channel capacity. The data are guaranteed to be valid.
Output
For each data set, print on its own line, in the same order as the input. Do not print any blank lines.