hihoCoder #1498 : Diligent Robots【数学】
#1498 : Diligent Robots
描述
There are N jobs to be finished. It takes a robot 1 hour to finish one job.
At the beginning you have only one robot. Luckily a robot may build more robots identical to itself. It takes a robot Q hours to build another robot.
So what is the minimum number of hours to finish N jobs?
Note two or more robots working on the same job or building the same robot won't accelerate the progress.
输入
The first line contains 2 integers, N and Q.
For 70% of the data, 1 <= N <= 1000000
For 100% of the data, 1 <= N <= 1000000000000, 1 <= Q <= 1000
输出
The minimum number of hours.
- 样例输入
-
10 1
- 样例输出
-
5
思路分析
首先,如果要复制机器,就要尽早复制,因为尽早复制可以尽早投入生产。
我的纠结点在于,复制的最后一轮,会不会有一部分机器人在复制,其他机器人在工作?
通过严谨的证明说明是不会的。
以下证明过程参考一位大神的,很严谨的证明,I love it!QAQ
因为我上面的证明里得到了“T>2qm”这个临界条件,因此在代码里可以直接使用。详解代码中已给出!
下面给出AC代码:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
ll n,q;
cin>>n>>q;//n表示任务总数,q表示生产一次机器人需要的时间
ll m=,r=;//m表示初始时机器人的数量,r表示生产次数
while(n>*m*q)//根据结论,机器人应当全部复制
{
m<<=;//倍增操作
r++;
}
ll t=q*r+n/m;//总时间为生产机器人所花费的时间q*r+任务数与机器人的比值(每个机器人单位时间生产单位价值的产品)
if(n%m)//不能整除的话说明t++;
t++;
cout<<t<<endl;
return ;
}
hihoCoder #1498 : Diligent Robots【数学】的更多相关文章
- HihoCoder - 1498 Diligent Robots
There are N jobs to be finished. It takes a robot 1 hour to finish one job. At the beginning you hav ...
- hihoCoder 1584 Bounce 【数学规律】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)
#1584 : Bounce 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 For Argo, it is very interesting watching a cir ...
- 【微软2017年预科生计划在线编程笔试第二场 B】Diligent Robots
[题目链接]:http://hihocoder.com/problemset/problem/1498 [题意] 一开始你有1个机器人; 你有n个工作; 每个工作都需要一个机器人花1小时完成; 然后每 ...
- hihoCoder #1234 : Fractal(数学简单题)
时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 This is the logo of PKUACM 2016. More specifically, the logo i ...
- hihoCoder1498-Diligent Robots
#1498 : Diligent Robots Time Limit:10000ms Case Time Limit:1000ms Memory Limit:256MB Description The ...
- hihocoder 1489(微软2017, 数学,模拟)
题目链接:http://hihocoder.com/problemset/problem/1489?sid=1587434 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 ...
- ACM学习历程—Hihocoder 1164 随机斐波那契(数学递推)
时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 大家对斐波那契数列想必都很熟悉: a0 = 1, a1 = 1, ai = ai-1 + ai-2,(i > 1). ...
- hihoCoder #1246 : 王胖浩与环 (数学)
题意: 有一个环形序列,可以将其切成连续的k段子序列,那么gcd( 每段子序列的和 )就是优美程度.输出n个整数,表示当k=[1, n] 时的最大优美程度. 思路: 观察一下,当切成1段的时候,gcd ...
- HihoCoder - 1789:阶乘问题 (简单数学)
描述 给定 n, k,求一个最大的整数 m,使得 km 是 n! 的约数 输入 第一行两个正整数 n, k 2 ≤ n,k ≤ 109 输出 输出最大的 m 样例输入 5 2 样例输出 3 思路:我们 ...
随机推荐
- springboot 入门七-静态资源处理
Spring Boot 默认配置的/**映射到/static(或/public ,/META-INF/resources),/webjars/**会映射到classpath:/META-INF/res ...
- iOS Button 上文字图片位置的设置
1. 添加图片+文字/文字+图片 ,不分前后,图片默认在文字前边 加空格隔开 UIButton * button =[[UIButton alloc] initWithFrame:CGRectMake ...
- NSQ之粗读浅谈
回顾: 以前一直是C++开发(客户端),最近听同事讲go语言不错,随后便决定先从go语法开始投向go的怀抱.由于历史原因学习go语法时,用了半天的时间看完了菜鸟教程上相关资料,后来又看了易百教程上的一 ...
- vue2 vue-rout
vue 2.0的路由比起1.0简单了许多,分为以下几个步骤: 1.创建路由块和视图块: to里面是要切换的路径名称 <div id="app"> <div> ...
- 浅析Node.js的Event Loop
目录 浅析Node.js的Event Loop 引出问题 Node.js的基本架构 Libuv Event Loop Event Loop Phases Overview Poll Phase The ...
- Using F2 to Rename Open Files
Copy to your User keymap { "keys": ["shift+f2"], "command": "rena ...
- QT中定时器的使用方法
前言:因为QT中用死循环会开销很多内存容易崩溃,这时候使用定时器可以很好解决这个问题. 使用定时器需要用到头文件:include<QTimer> (1)定义定时器 QTimer *upda ...
- jQuery 文档操作方法
jQuery 文档操作方法 这些方法对于 XML 文档和 HTML 文档均是适用的,除了:html(). 方法 描述 addClass() 向匹配的元素添加指定的类名. after() 在匹配的元素之 ...
- sql存储过程中使用 output
1.sql存储过程中使用 output CREATE PROCEDURE [dbo].[P_Max] @a int, -- 输入 @b int, -- 输入 @Returnc int output - ...
- collections --Counter
collections 模块--Counter 目的是用来跟踪值出现的次数.是一个无序的容器类型,以字典的键值对形式存储,其中元素为 key,其计数作为 value.计数值可以是任意的 Integer ...