链接:

https://vjudge.net/problem/LightOJ-1275

题意:

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 - T*N). The problem is to compute 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 the optimal T are integer numbers.

思路:

函数最大值,直接计算,顺便再求下误差。

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map> using namespace std;
typedef long long LL;
const int INF = 1e9; const int MAXN = 1e6+10;
const int MOD = 1e9+7; int main()
{
int t, cnt = 0;
int n, c;
scanf("%d", &t);
while(t--)
{
printf("Case %d: ", ++cnt);
scanf("%d%d", &n, &c);
if (n == 0)
{
puts("0");
continue;
}
int res = c/(2*n);
if ((res+1)*(c-(res+1)*n) > (res*(c-res*n)))
res = res+1; printf("%d\n", res);
} return 0;
}

LightOJ-1275-Internet Service Providers(数学)的更多相关文章

  1. 1275 - Internet Service Providers

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

  2. POJ 3911:Internet Service Providers

    Internet Service Providers Time Limit: 2MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I ...

  3. Laravel 之Service Providers

    Service providers are the central place of all Laravel application bootstrapping. Your own applicati ...

  4. Custom Data Service Providers

    Custom Data Service Providers Introduction Data Services sits above a Data Service Provider, which i ...

  5. 自定义Data Service Providers

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

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

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

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

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

  8. Internet 校验和的数学性质

    Internet 校验和(Checksum)仅计算头部的正确性,这一点很重要,这意味着 IP 协议不检查 IPv4 packet 有效载荷部分的数据正确性.为了保证有效载荷部分的正常传输,其他协议必须 ...

  9. lightoj 1148 Mad Counting(数学水题)

    lightoj 1148 Mad Counting 链接:http://lightoj.com/volume_showproblem.php?problem=1148 题意:民意调查,每一名公民都有盟 ...

随机推荐

  1. Linux下创建Oracle19C的数据库实例

    接上一篇博客,安装 Oracle19chttps://www.cnblogs.com/xuzhaoyang/p/11264557.html 切换到root用户下,切换目录到db_1,执行,遇到选择路径 ...

  2. [转帖]Linux企业运维人员最常用150个命令汇总

    Linux企业运维人员最常用150个命令汇总 https://clsn.io/clsn/lx998.html 基本上都用过了. 命令 功能说明 线上查询及帮助命令(2个) man 查看命令帮助,命令的 ...

  3. SpringBoot(1)

    SpringBoot 8/2 CRUD 发送put请求修改数据有三个步骤: SpringMVC中配置HiddenHttpMethodFilter 页面上创建一个post请求(form标签只能写get和 ...

  4. 关于类视图选择继承APIView还是工具视图(ListAPIView、CreateAPIView等等)

    APIView使用方法,直接继承APIView,get或者post请求.方法很简单1.先获取到要操作的数据,然后把数据放到serializer中序列化或者反序列化,最后return返回值(记得.dat ...

  5. Microsoft.AspNet.Identity 自定义使用现有的表—登录实现,aspnet.identity

    Microsoft.AspNet.Identity是微软新引入的一种membership框架,也是微软Owin标准的一个实现.Microsoft.AspNet.Identity.EntityFrame ...

  6. JS获取时间差

    Date.parse(String string)转为毫秒数进行比较

  7. Office 365 的安装与激活

    (1)Office 365的安装,本处使用的是Office Tool Plus. (2)等待安装完成 (3)重头戏激活 , 使用命令行方式 (不推荐) 以下内容,新建文本文件,然后保存为.bat,再以 ...

  8. 为新装的Centos 7X更换源,升级VIM失败,待解决

    CentOS 7X使用阿里云CentOS的yum源 1.备份原有repo文件 #cd /etc/yum.repos.d #mv /etc/yum.repos.d/CentOS-Base.repo /e ...

  9. apache的虚拟域名rewrite配置以及.htaccess的使用。

    在web服务器领域,Apache基本上是一统天下的,虽然现在越来越多的人转向nginx的,但是仍然由于apache的高性能以及强大的功能,还是大多数服务器在使用Apache. apache的安装就先不 ...

  10. Java 之 Servlet中的生命周期

    Servlet 生命周期 一.重写servlet方法 当创建一个类,继承 servlet 这个接口时,需要实现里面的抽象方法. import javax.servlet.*; import java. ...