URAL 1131. Copying (math)
来源:互联网 发布:oracle数据库外键约束 编辑:程序博客网 时间:2024/05/28 15:08
1131. Copying
Time limit: 0.25 second
Memory limit: 64 MB
Memory limit: 64 MB
A new educating program was received by the kindergarten. Of course, children have discovered it immediately and want to play with it as soon as possible. In order to let them do it the program has to be copied to all theN computers that the kindergarten had bought just before the default of 1998. At the moment the program is installed only on one computer. Other computers do not have floppy drives and are not connected with a local network. The only way to transfer information from one computerto another is to copy it using a null-modem cable (a cable that connects two computers directly). So, if the program is installed on a computer, it can be copied to some other (but only one!) computer within an hour. There are only K null-modem cables in the kindergarten. Your task is to estimate the minimal time necessary for copying the program to all the computers in the kindergarten.
Input
The only input line contains two integers separated with a space:Nand K (1 ≤ N ≤ 109; 1 ≤ K ≤ 109).
Output
You are to output the minimal time (in hours) necessary for copying of the program to all the computers.
Sample
8 3
4Problem Author: Stanislav Vasilyev, Alexander Mironenko
Problem Source: VI Ural State University Collegiate Programming Contest (21.10.2001)
解析:每个接口两端只能连两台电脑,这就代表了一台电脑只能同时为一台电脑传送数据。并且每小时一台电脑。直接模拟计算即可。
AC代码:
#include <bits/stdc++.h>using namespace std;int main(){ int n, k, ans; scanf("%d%d", &n, &k); for(ans = 0; (1 << ans) < k && (1 << ans) < n; ans ++) ; if((1 << ans) < n) ans += (n - (1 << ans) - 1) / k + 1; printf("%d\n", ans); return 0;}
0 0
- URAL 1131. Copying (math)
- URAL 1796. Amusement Park (math)
- URAL 2025. Line Fighting (math)
- 1131. Copying
- ural 1133. Fibonacci Sequence math
- ural 1049. Brave Balloonists math
- Copying Books (二分法)
- Copying Books--(二分)
- Copying Books (二分)
- ural 1084. Goat in the Garden math
- 714 - Copying Books(二分)
- UVA714:Copying Books(抄书)
- POJ1505 Copying Books(dp)
- URAL 1036. Lucky Tickets java.math.BigInteger模板
- Timus 1131. Copying 数学公式的构造
- 拷贝集合类(Copying Collections)
- Codeforces 292E(Copying Data)
- uva 714 - Copying Books(二分+贪心)
- Selenium WebDriver使用IE浏览器
- 黑马程序员--Java学习日记之复习总结(递归以及IO流概述)
- 详谈OC(object-c)深浅复制/拷贝-什么情况下用retain和copy
- android private libraries中的jar添加源码文件过程
- js中setTimeout与setInterval
- URAL 1131. Copying (math)
- QQ智能聊天机器人设想
- 黑马程序员--Java学习日记之总结复习(多线程和设计模式)
- Java基础知识小结 二 (自学)
- IOS学习之NSTimer使用详解
- PHP中this,self,parent的区别
- View 中 setTag & getTag
- localStorage请使用getItem 和setITem
- jQuery CSS 操作函数