hdu4803
2015-11-14 20:40
537 查看
#include <cstdio> #include <cmath> #define eps 1e-5 using namespace std; double x,y; int ans,n; int main() { while (scanf("%lf%lf",&x,&y)!=EOF) { ans=(int)(x-1); y-=x-1+eps; if (y<0) { printf("-1\n"); continue; } for (int i=1; i<=x; i++) { n=(int)(i*y/x); ans+=n; y-=n*x/i; if (y<1) break; } printf("%d\n",ans); } return 0; }
相关文章推荐
- 从头认识java-8.11 为什么需要内部类?
- 119 Pascal's Triangle II
- Tomcat不能启动注意事项
- java 子类重写父类的方法应注意的问题
- K-means聚类算法
- 102 Binary Tree Level Order Traversal
- html 内联元素 块元素
- hdu3394Railway【双连通分量+模板详细解释】
- 决策树算法
- 20151114 shell脚本控制oracle随系统启动
- 112 Path Sum
- 10010---JavaWeb基础--HttpServlet
- Linux下的GPT分区
- 225 Implement Stack using Queues
- 动态页面jsp转换为html静态的网页
- 今天来学习下美团推荐算法实践:机器学习重排序模型
- pip安装mysql-python报致命错误:my_config.h:没有那个文件或目录
- 多态
- 172 Factorial Trailing Zeroes
- 118 Pascal's Triangle