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. 实践 Network Policy 【转】

    为了演示 Network Policy,我们先部署一个 httpd 应用,其配置文件 httpd.yaml 为: httpd 有三个副本,通过 NodePort 类型的 Service 对外提供服务. ...

  2. HihoCoder第一周与POJ3974:最长回文字串

    这个题目是hihoCoder第一周的题目,自己打算从第一周开始做起,不知道能追上多少,更不知道这一篇写完,下一篇会是什么时候... 题意很简单. 输入: abababa aaaabaa acacdas ...

  3. 第1节 IMPALA:3、impala软件的下载和linux磁盘的挂载

    1. impala安装软件下载: http://archive.cloudera.com/cdh5/repo-as-tarball/5.14.0/ 2. linux磁盘的挂载: [root@node0 ...

  4. 洛谷 P2031 脑力达人之分割字串

    题目传送门 解题思路: f[i]表示到第i位可获得的最大分割次数,对于每个f[i]都可由其符合条件的前缀转移过来,条件就是当前串除了前缀的剩余字符里有所给单词,然后一看,这不是在剩余字符里找有没有所给 ...

  5. prepareRefresh方法源码跟踪

    看这篇文章之前可以先了解之前的跟踪流程,https://www.jianshu.com/p/4934233f0ead 代码过宽,可以shift + 鼠标滚轮 左右滑动查看 AbstractApplic ...

  6. H5易企秀

    周末被领导叫回来加班,说要做一个易企秀一样的页面,然后就有这篇笔记 原计划用几百个计时器去执行,后面放弃了,太难改了,还是选择了animate.css插件,这是一个纯css的插件,只需要引入css就行 ...

  7. symbol数据类型

    symbol声明的类型独一无二 概念:表示独一无二的值,永远不相等 s1 = Symbol() s2 = Symbol() s1 !== s2 基本使用: 通过Symbol函数生成,得到一个symbo ...

  8. python 编写程序输出50以内勾股数,如下图所示,要求每组显示六祖,各组勾股数无重复

    import math n = 0 for a in range(1,49): for b in range(a,49): c = math.ceil(math.sqrt(a**2+b**2)) if ...

  9. eclipse中使用jstl

    错误提示为"can not find the tag library for http://java.sun.com/jsp/jstl/core" 这是我在练习把axis2和普通j ...

  10. 在 Windows 系统上安装 Jekyll

    目录 安装 Ruby 环境 用 Bundler 安装 Jekyll 本文是写给完全未用过 Ruby 乃至命令行工具者的.对于一般的开发者,Jekyll 官方文档的相关内容已然足够. 本文为钱院学辅技术 ...