GYM 100030 D.Broadcasting(水~)
来源:互联网 发布:淘宝收藏店铺上限 编辑:程序博客网 时间:2024/06/08 09:40
Description
n台电脑,两两相连可以互传数据,每台电脑每秒可以同时给k台电脑传数据,现在只有1台电脑有数据,问最少需要几秒使得所有电脑都有该数据
Input
两个整数n和k分别表示电脑数量和一台电脑每秒最多可以传输数据的电脑数(1<=n,k<=1e9)
Output
输出使得是所有电脑都有数据所需的最少时间
Sample Input
4 1
Sample Output
2
Solution
答案即为满足(k+1)^x>=n的最小x
Code
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;#define INF 0x3f3f3f3f#define maxn 1111int main(){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); ll k,n; while(~scanf("%I64d%I64d",&n,&k)) { int ans=0; ll temp=1; while(temp<n) { temp*=(k+1); ans++; } printf("%d\n",ans); } return 0;}
0 0
- GYM 100030 D.Broadcasting(水~)
- GYM 100247 D. Hamming Distance(水~)
- GYM 100182 D.Knitting(水~)
- GYM 101147 D.Popcorn(水~)
- Codeforces GYM 100651 D I Conduit! (水计算几何)
- GYM 101086 D.Secure but True(水~)
- Broadcasting
- Gym 100917D dir -C(RMQ)
- Gym 100712D Alternating Strings (dp)
- Gym 100531D Digits(暴力)
- GYM 100090 D.Insomnia(递归)
- GYM 100488 D.Toy Soldiers(map)
- GYM 100827 D.Function(高斯消元)
- GYM 101128 D.Dice Cup(概率)
- GYM 101102 D.Rectangles(单调栈)
- GYM 100971 D.Laying Cables(set)
- GYM 100030 K.Triskaidekaphobia(水~)
- GYM 100285 D. This cheeseburger you don’t need(水~)
- android 服务service
- PAT (Advanced Level) 1126. Eulerian Path (25) 解题报告
- PAT 1080-Graduate Admission (30)
- iOS推送通知的证书设置
- springmvc框架报错java.lang.IllegalArgumentException: No converter found for return value of type: class
- GYM 100030 D.Broadcasting(水~)
- JavaBean简单及使用
- linux环境下整合nginx1.8.0和tomcat7负载均衡配置
- 得到分页列表的分页数据
- 图书管理程序管理员界面
- 【TensorFlow】tf.nn.conv2d是怎样实现卷积的?
- 关于在windows 下安装scrapy的问题
- 训练21-HTML 设置链接锚元素外部页面
- 常用框架、库