POJ 3911:Internet Service Providers
Time Limit: 2MS | Memory Limit: 65536KB | 64bit IO Format: %I64d & %I64u |
Description
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
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的更多相关文章
- 1275 - Internet Service Providers
1275 - Internet Service Providers PDF (English) Statistics Forum Time Limit: 2 second(s) Memory L ...
- 自定义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 ...
- LightOJ-1275-Internet Service Providers(数学)
链接: https://vjudge.net/problem/LightOJ-1275 题意: A group of N Internet Service Provider companies (IS ...
- Angular:ViewProviders和Providers的区别
在Angular中使用依赖注入(DI)的时候,我们一般会使用providers.其实要做同样的事我们还有另外一个选择:viewProviders. viewProviders允许我们定义只对组件的vi ...
- SSRS2:Reporting Service 配置Service Account
1,Service Account SSRS以一个Service方式实现,有三部分组成:Web Service,Report Manager和一个后台的进程,这个Service运行的账号就是Servi ...
- Android总结篇系列:Android Service
Service通常总是称之为“后台服务”,其中“后台”一词是相对于前台而言的,具体是指其本身的运行并不依赖于用户可视的UI界面,因此,从实际业务需求上来理解,Service的适用场景应该具备以下条件: ...
- WCF分布式开发必备知识(3):Web Service 使用
参考地址:http://www.cnblogs.com/zhili/p/WebService.html 一.WebService概述 SOAP.WSDL.UDDISOAP(Simple Object ...
随机推荐
- Ubuntu下安装 Mysql
MYSQL在ubuntu16.04下的编译安装mysql-5.6.23.tar.gz 为减少安装过程中因权限带来个各种问题,建议全程用root用户编译安装,步骤如下: 1.安装依赖文件 apt-ge ...
- spoj694--Distinct Substrings
个人第一道后缀数组题目.对于每一个后缀suffix(i),都有len-sa[i]个前缀(也即有len-sa[i]个不同的字符串),其中与排名前一位的后缀有height[i]个共同的前缀,最后所得到的新 ...
- 如何将dmp文件导入到Oracle
一.概述 在将dmp文件导入到Oracle中之前,需要先创建一个orcale用户.然后使用该用户名和密码,以imp的方式将数据导入到oracle中. 二.执行步骤 1.登陆oracle数据库 a.sq ...
- tab选项卡,不带自动切换定时器
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content ...
- 2.11 学习总结 之 ajax
一.说在前面 昨天 学习了 json 数据结构 今天 学习ajax 并使用 json 二.jquery的ajax操作 1.查询jquery的官方文档发现与ajax相关的jquey方法如下: 1)$. ...
- Exchange 2003 群集迁移 & SPS 2003 迁移、SQL Server 2000群集
哈哈,本人自己写的文档,内容太多了,有195页,上传到Blog里面,应该是很难看的,排版也不太好. 记得下载时后改名字,用WinRAR解压合并. 第1章 迁移环境介绍 第2章 共享磁盘柜配置 第3章 ...
- 批量处理文件的Python程序
经常批量处理文件,这里有个python的模板,保存一下 这个例子是把目录里面所有子目录的mp3文件放慢0.85倍并保存到./processed/目录下面. #coding=utf-8 import s ...
- CSS屏幕适配尺寸样式
/* 大屏幕 :大于等于1200px*/@media (min-width: 1200px) { ... } /*默认*/@media (min-width: 980px){...} /* 平板电脑和 ...
- C++编程学习(七) 循环结构
1.continue:循环体中结束本次循环,直接进入下一次循环. 2.break:循环直接结束. 3.在for语句循环体中执行continue语句,程序会转到“表达式3”继续运行. 4.使用多重循环的 ...
- 090-PHP数组过滤函数array_filter
<?php function odd($x){ //定义过滤偶数的函数 if($x%2==1) return TRUE; } function even($x){ //定义过滤奇数的函数 if( ...