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 题意:民意调查,每一名公民都有盟 ...
随机推荐
- SQL——BETWEEN操作符
一.BETWEEN操作符的基本用法 BETWEEN操作符用于选取两个值范围内的值. 语法格式如下: SELECT 列名1,列名2... FROM 表名 WHERE 列名 BETWEEN 值1 AND ...
- 33 Eclipse无法查看源码解决
问题如图 点击 Attach Source 解决方法 下载src.zip包,src包地址:https://pan.baidu.com/s/1oAqqqHO 选择此src包即可
- mysql网文收录
1.分布式事务 1) 聊聊分布式事务,再说说解决方案 https://www.cnblogs.com/savorboard/p/distributed-system-transaction-cons ...
- LOJ6300 博弈论与概率统计 组合、莫队
传送门 如果在\(0\)以下之后仍然会减分,那么最后的结果一定是\(N-M\). 注意到如果在Alice分数为\(0\)时继续输,那么就相当于减少了一次输的次数.也就是说如果说在总的博弈过程中,Ali ...
- vmware下的linux没有网络问题解决思路
这里几天一直在搞vm下的linux主机的网络问题,这里做个总结 这里使用的NAT连接方式 1.首先保证本机联网正常 2.检查虚拟机相应的服务(VMware NET Service 和 VMware W ...
- oracle 触发器的实例(转)
触发器使用教程和命名规范 目 录 目录 触发器使用教程和命名规范 1 1,触发器简介 1 2,触发器示例 2 3,触发器语法和功能 3 4,例一:行级触发器之一 4 5,例二:行级触发器之二 4 6 ...
- YII 的SPA 写法
'use strict'; var findToolbar = function () { return document.querySelector('#yii-debug-toolbar'); } ...
- Golang-使用md5对字符串进行加密
方式一: func md5Test1(str string) string { m5 := md5.New() _,err := m5.Write([]byte(str)) if err != nil ...
- android 给ImageView设置路径
ImageView是Android程序中经常用到的组件,它将一个图片显示到屏幕上. 在UI xml定义一个ImageView如下: public void onCreate(Bundle savedI ...
- Python学习日记(八) 函数
函数的结构: 函数的返回值: 1.当函数执行时运到return关键字将不再往下执行 def func(): print("hello world!") print("he ...