LightOJ-1275-Internet Service Providers(数学)
链接:
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(数学)的更多相关文章
- 1275 - Internet Service Providers
1275 - Internet Service Providers PDF (English) Statistics Forum Time Limit: 2 second(s) Memory L ...
- POJ 3911:Internet Service Providers
Internet Service Providers Time Limit: 2MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I ...
- Laravel 之Service Providers
Service providers are the central place of all Laravel application bootstrapping. Your own applicati ...
- Custom Data Service Providers
Custom Data Service Providers Introduction Data Services sits above a Data Service Provider, which i ...
- 自定义Data Service Providers
自定义Data Service Providers 作者:AlexJ 翻译:谈少民 原文链接:http://blogs.msdn.com/b/alexj/archive/2010/01/07/data ...
- Hyperledger Fabric Membership Service Providers (MSP)——成员服务
Membership Service Providers (MSP) 本文将介绍有关MSPs的设置和最佳实践的详细方案. Membership Service Providers (MSP)是一个旨在 ...
- 使用SAP云平台 + JNDI访问Internet Service
以Internet Service http://maps.googleapis.com/maps/api/distancematrix/xml?origins=Walldorf&destin ...
- Internet 校验和的数学性质
Internet 校验和(Checksum)仅计算头部的正确性,这一点很重要,这意味着 IP 协议不检查 IPv4 packet 有效载荷部分的数据正确性.为了保证有效载荷部分的正常传输,其他协议必须 ...
- lightoj 1148 Mad Counting(数学水题)
lightoj 1148 Mad Counting 链接:http://lightoj.com/volume_showproblem.php?problem=1148 题意:民意调查,每一名公民都有盟 ...
随机推荐
- [转帖]B树索引和位图索引的结构介绍
B树索引和位图索引的结构介绍 http://blog.itpub.net/12679300/viewspace-1174236/ 一 前言:? ROWID:包含键值的行的行ID,(查找块的最快方法, ...
- 《学渣的电子技术自学笔记》——二极管的工作频率与PN结结面积的关系
<学渣的电子技术自学笔记>--二极管的工作频率与PN结结面积的关系 书本原文 :按结构分,二极管有点接触型.面接触型和平面型三类.点接触型二极管(一般为锗管)的PN结结面积很小(结电容小) ...
- Shell基础快速入门 了解shell运行原理
Shell简介 Shell 是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁.Shell 既是一种命令语言,又是一种程序设计语言. Shell 是指一种应用程序,这个应用程序提供了一个界 ...
- Oracle 11g 总结篇2
第一部分: 字段名的别名用""括起来,如:last_name as "姓名". 去除重复:在投影的字段名前加上 distinct 就可以了. 比如:select ...
- ADO.NET 一般操作(c#)
ADO.NET五大对象:SqlConnection.SqlCommand.SqlDataReader.SqlDataAdapter .DataSet ,其中SqlDataAdapter 不建议使用 一 ...
- VsCode 解决vim插件,不能使用ctrl+c的问题(目标卸载im)
VsCode中,使用VIM插件后,ctrl+c不能用 可以通过 File -> Preference -> Settings中 vim.useCtrlKeys 选项设置为 false ...
- 【转载】C#中string类使用Replace方法来替换字符串
在C#的字符串操作过程中,有时候需要替换字符串中的某个子字符串,此时就可以使用到字符串类自带的Replace方法来实现,Replace方法将查找到所有符合被替换的子字符串,然后将之全部替换为目标字符串 ...
- 【转载】C#使用Math.Ceiling方法对计算结果向上取整操作
在C#的数值运算中,有时候需要对计算结果进行向上取整操作,支持设定结算结果的有效位数,Math.Ceiling方法是C#中专门用来对数值进行向上取整的方法,此方法和Math.Round方法.Math. ...
- tp框架防止表单重复提交
转载 框架官方 http://www.thinkphp.cn/topic/9090.html 第三方 https://my.oschina.net/caomenglong/blog/728908
- GitHub上传文件夹
1.输入自己的用户名和邮箱 为注册GitHub账号时所用的用户名和邮箱;我的用户名为“1997ST2016”,邮箱为“1324971964@qq.com ”. $ git config --globa ...