POJ2590 Steps
来源:互联网 发布:富二代体验知乎 编辑:程序博客网 时间:2024/05/22 15:25
题目链接:http://poj.org/problem?id=2590
解题思路:
水题,找规律。
AC代码:
#include<iostream>#include<cstdio>#include<cmath>using namespace std;int main(){ int T; scanf("%d",&T); while(T--) { int x,y,step; scanf("%d%d",&x,&y); int t=y-x; int a=sqrt(t*1.0); int b=a*(a+1); if(b>t) { if(a*(a-1)+a<t) step=2*a; else step=2*a-1; } else if(t-b==0) step=2*a; else if(t-b>a) step=2*a+2; else step=2*a+1; printf("%d\n",step); } return 0;}
0 0
- POJ2590:Steps
- POJ2590 Steps
- poj2590-steps
- ZOJ1871 POJ2590 Steps
- poj2590
- 北大ACM poj2590
- Steps
- Steps
- Steps
- Steps
- Steps
- Steps
- Steps
- steps
- Steps
- steps
- Number Steps
- Number Steps
- IntelliJ IDEA 14 注册机代码
- IntelliJ IDEA 14 注册机代码
- HDU5139 Formula && BestCoder Round #21 1002
- POJ 1003 Hangover
- POJ1218 THE DRUNK JAILER
- POJ2590 Steps
- POJ2105 IP Address
- POJ2365 Rope
- [转]Android蓝牙开发浅谈
- POJ1298 The Hardest Problem Ever
- Flume+kafka+storm整合
- systemctl替代service与chkconfig
- HDU1028 Ignatius and the Princess III(母函数模板)
- POJ 2328 解题报告