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 题意:民意调查,每一名公民都有盟 ...
随机推荐
- python_scratch教程:绘制荧光圈教程
在演唱会中,出现最多的就是荧光棒,很多粉丝也都会举着荧光棒为自己的爱豆加油,当然也会有一些人用的荧光圈,为此南京小码王scratch培训机构,就想到了和小朋友一起绘制荧光圈,现在我们就一起来看看吧! ...
- Git手册(一):基本操作
Git小册 本手册参考自runoob及其他网络资源,仅用于学习交流 Git工作流程 一般工作流程 1.克隆 Git 资源作为工作目录. 2.在克隆的资源上添加或修改文件. 3.如果其他 ...
- 计算GPA
#include <stdio.h> int main() { int n,t,i; float sum,s,p,m,k; while(~scanf("%d",& ...
- [洛谷U72177]火星人plus
题目大意:给你一个$1\sim n(n\leqslant 10^5)$的排列,设$a$为它在$1\sim n$的全排列中的排名,求在$1\sim n$的全排列中第$a+m$个排列. 题解:康托展开以及 ...
- CF1097G Vladislav and a Great Legend 组合、树形背包
传送门 看到\(k\)次幂求和先用斯特林数拆幂:\(x^k = \sum\limits_{i=1}^k \binom{x}{i}\left\{ \begin{array}{cccc} k \\ i \ ...
- js获取项目名称
//获取路径 var pathName=window.document.location.pathname; //截取,得到项目名称 var projectName=pathName.substrin ...
- ActiveX的AssemblyInof.cs文件 IObjectSafety 接口
ActiveX的AssemblyInof.cs文件 IObjectSafety 接口 [Guid("D4176A17-2A33-4903-8F37-9EBDD7CAFFD3"), ...
- CarbonCopyCloner 硬盘对拷
CarbonCopyCloner 硬盘对拷 建议使用 5.1.14-b1以上的版本. 安装文件包 CarbonCopyCloner-5.1.14-b1.dmg ================== E ...
- number与string的转换
// number -> string // toString() /* var num = 10; var res = num.toString(); alert(typeof (num)); ...
- vue动态加载图片
如果是直接动态获取完整的图片地址可以使用以下方法 <template> <img :src="url"> </template> <scr ...