Time Limit: 2MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u

Status

Description

A group of N Internet Service Provider companies (ISPs) use a private communication channel that has a maximum capacity of C traffic units per second. Each company transfers T traffic units per second through the channel and gets a profit that is directly proportional
to the factor T(C - TN). The problem is to compute T_optim, the smallest value of T that maximizes the total profit the N ISPs can get from using the channel. Notice that N, C, T, and T_optim are integer numbers.

Input

Each data set corresponds to an instance of the problem above and contains two integral numbers – N and C – with values in the range from 0 to 10 9. The input data are separated by white spaces, are correct, and terminate with an end of file.

Output

For each data set the program computes the value of T_optim according to the problem instance that corresponds to the data set. The result is printed on the standard output from the beginning of a line. There must be no empty lines on the output.

Sample Input

1 0
0 1
4 3
2 8
3 27
25 1000000000

Sample Output

0
0
0
2
4
20000000

求一个一元二次方程取极值时x的值。-b/(2*a)。。。

因为程序里面除法可能消掉了一部分小数,所以还要判断x+1时的情况,比较一下再输出。

代码:

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std; int main()
{
//freopen("i.txt","r",stdin);
//freopen("o.txt","w",stdout); long long n,c;
while(scanf("%lld%lld",&n,&c)!=EOF)
{
if(n==0)
{
cout<<0<<endl;
continue;
}
else
{
long long x=c/(2*n);
long long y=x+1;//一开始竟写成了减1。。。
cout<<(x*(c-n*x)<y*(c-n*y)?y:x)<<endl;
}
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

POJ 3911:Internet Service Providers的更多相关文章

  1. 1275 - Internet Service Providers

    1275 - Internet Service Providers    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory L ...

  2. 自定义Data Service Providers

    自定义Data Service Providers 作者:AlexJ 翻译:谈少民 原文链接:http://blogs.msdn.com/b/alexj/archive/2010/01/07/data ...

  3. Hyperledger Fabric Membership Service Providers (MSP)——成员服务

    Membership Service Providers (MSP) 本文将介绍有关MSPs的设置和最佳实践的详细方案. Membership Service Providers (MSP)是一个旨在 ...

  4. 使用SAP云平台 + JNDI访问Internet Service

    以Internet Service http://maps.googleapis.com/maps/api/distancematrix/xml?origins=Walldorf&destin ...

  5. LightOJ-1275-Internet Service Providers(数学)

    链接: https://vjudge.net/problem/LightOJ-1275 题意: A group of N Internet Service Provider companies (IS ...

  6. Angular:ViewProviders和Providers的区别

    在Angular中使用依赖注入(DI)的时候,我们一般会使用providers.其实要做同样的事我们还有另外一个选择:viewProviders. viewProviders允许我们定义只对组件的vi ...

  7. SSRS2:Reporting Service 配置Service Account

    1,Service Account SSRS以一个Service方式实现,有三部分组成:Web Service,Report Manager和一个后台的进程,这个Service运行的账号就是Servi ...

  8. Android总结篇系列:Android Service

    Service通常总是称之为“后台服务”,其中“后台”一词是相对于前台而言的,具体是指其本身的运行并不依赖于用户可视的UI界面,因此,从实际业务需求上来理解,Service的适用场景应该具备以下条件: ...

  9. WCF分布式开发必备知识(3):Web Service 使用

    参考地址:http://www.cnblogs.com/zhili/p/WebService.html 一.WebService概述 SOAP.WSDL.UDDISOAP(Simple Object ...

随机推荐

  1. SpringMVC一点简单地源码解析

    . 1.1 init(初始化) 在第一次发出请求时,会调用HttpServletBean 的init()方法 org.springframework.web.servlet.HttpServletBe ...

  2. JDK8~JDK11的新特性

    #JDK 1.8 新特性接口中的静态方法 只能由接口自己调用 接口中的默认方法 可以不被覆盖 #JDK 1.9 新特性(可能在JDK8中被忽略了,没来得及加)接口可以定义私有方法,但是只能让自己调用, ...

  3. linux 查看ip、用户、时间对应执行的命令

    这个需要使用到history命令.可以加数字,返回最近执行的几条命令.如果不加数字会返回所有的历史命令. [root@localhost ~]# history 20 1015 rm stdin.lo ...

  4. 002-var_dump用法

    <?php $a = 2150; //小刘的工资2150 $b = 2240; //小李的工资2240 echo "a=" . $a . "  b=" . ...

  5. pyhton输出表格数据出现省略号?(教你很快解决)

    //2019.07.18 pandas是python提供的非常好用的数据分析模块,但是在使用pandas进行数据分析时,有时候需要查看打印的结果,当dataframe行数或者列数比较多的时候,打印结果 ...

  6. 安装phpmyadmin数据可视化

    1.下载压缩包,并且解压 cd /usr/local/src wget https://files.phpmyadmin.net/phpMyAdmin/4.9.4/phpMyAdmin-4.9.4-a ...

  7. Si7006主要面向传统上使用的分立RH / T传感器的低精度的应用

    Silicon Labs的Si7006 / 13/20/21个I 2 C相对湿度及温度传感器结合充分工厂校准湿度和温度传感器元件与模拟-数字转换器,信号处理和一个I 2 C主机接口.专利使用业界标准低 ...

  8. linux添加一个已经存在用户到一个用户组

    在使用virtual-box的共享文件时,在虚拟机中共享文件的用户为root,用户组为vboxsf, 所以需要将自己添加到vboxsf这组当中去,一开始使用useradd老是失败,后来才查到要用use ...

  9. 二十、JavaScript之对象

    一.代码如下 二.执行效果如下 <!DOCTYPE html> <html> <meta http-equiv="Content-Type" cont ...

  10. 八十七、SAP中ALV事件之一,事件的声明

    一.我们双击"REUSE_ALV_GRID_DISPLAY",来到SE37界面, 二,来到这儿,点击SLIS_T_EVENT, 三.可以看到SLIS_T_EVENT的定义,有一个n ...