uva846:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=787

题意:给你两个数x,y,x<=y,现在让你从x走向y,开始的第一次和最后一次,只能够移动一步,之后每一次走的步数和上次走的步数之和之差不超过1.问你到达y最小需要多少步。

题解:从x,y同时开始走,每次步数加一,如果走到两者刚好相遇则停止,如果剩余的距离不超过当前的步数,也可以停止,因为这剩余的距离可以在之前的某个时间段走完,相当于在之前走了一个水平的阶段。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int x,y;
int main(){
int cas;
scanf("%d",&cas);
while(cas--){
scanf("%d%d",&x,&y);
int counts=,step=;
while(){
if(x>=y){
printf("%d\n",*counts);
break;
}
if(y-x<=step){
printf("%d\n",*counts+);
break;
}
else{
x+=step;
y-=step;
counts++;
step++;
}
}
}
}

Steps的更多相关文章

  1. animation-timing-function: steps() 详解

    在应用 CSS3 渐变/动画时,有个控制时间的属性 <animation-timing-function> .它的取值中除了常用到的 贝萨尔曲线以外,还有个让人比较困惑的 steps()  ...

  2. CSS3 Animation 帧动画 steps()

    @keyframes fn{ 0%{} 100%{} } CSS3的Animation有八个属性 animation-name :动画名 fn animation-duration:时间 1s ani ...

  3. SAML 2.0 setup steps, 效果图

    Steps of setting up SAML SSO. 效果图 # Registry a Identity Provider services in:(Might need purchase) I ...

  4. 【译】css动画里的steps()用法详解

    原文地址:http://designmodo.com/steps-c... 原文作者:Joni Trythall 我想你在css 动画里使用steps()会和我一样有很多困惑.一开始我不清楚怎样使用它 ...

  5. css3动画中的steps值详解

    css3的动画的animation-timing-function属性定义了动画的速度曲线,一般的速度曲线大家都知道,什么ease,linear,ease-in,ease-out,还有自定义贝塞尔曲线 ...

  6. steps animation

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. sdutoj 2623 The number of steps

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2623 The number of steps ...

  8. SAP NWBC for HTML and Desktop configuration steps[From sdn]

    Summary :- This dcoumnenst conatin the information about requirement , hardware , configuration step ...

  9. 【转载】7 Steps for Calculating the Largest Lyapunov Exponent of Continuous Systems

    原文地址:http://sprott.physics.wisc.edu/chaos/lyapexp.htm The usual test for chaos is calculation of the ...

  10. BSGS算法_Baby steps giant steps算法(无扩展)详解

    Baby Steps-Varsity Giant Step-Astronauts(May'n・椎名慶治) 阅读时可以听听这两首歌,加深对这个算法的理解.(Baby steps少女时代翻唱过,这个原唱反 ...

随机推荐

  1. Java中类的初始化

    类从被加载到虚拟机内存中开始,到卸载出内存为止,它的整个生命周期包括:加载.验证.准备.解析.初始化.使用和卸载七个阶段.其中验证.准备.解析3个部分统称为连接.类加载的过程包括了加载.验证.准备.解 ...

  2. javascrip实现无缝滚动

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. Hadoop2.6.0在Ubuntu Kylin14.04上的配置

    最近几天在忙参加一个云计算比赛,之前也在Ubuntu上配成功过hadoop,不过是按照书上讲的,一步一步来的.因此,印象不深,对自己的帮助也不大.这次趁着机会,自己练了两遍配置过程,感觉收获比较丰富, ...

  4. C# 解析js方法,并调用js方法

    本文转载:http://www.cnblogs.com/StudyLife/archive/2013/03/11/2953516.html 本文不是基于B/S的 后台调用前台js方法,而是给你一段js ...

  5. android图片缓存框架Android-Universal-Image-Loader(二)

    http://blog.csdn.net/king_is_everyone/article/details/35595515 这篇打算直接告诉大家怎么用吧,其实这个也不是很难的框架,大致使用过程如下: ...

  6. 使用 Java 配置进行 Spring bean 管理--转

    概述 众所周知,Spring 框架是控制反转 (IOC) 或依赖性注入 (DI) 模式的推动因素,而这种推动是通过基于容器的配置实现的.过去,Spring 允许开发人员使用基于 XML 的配置,通过利 ...

  7. git 取消/添加 某文件的跟踪

    如果我们不小心将某个文件加入了 git 版本控制,但是突然又不想继续跟踪控制这个文件了,怎么办呢? 使用 git update-index 即可. 不想继续追踪某个文件 git update-inde ...

  8. Linux防火墙配置

    防火墙命令 service iptables stop --停止 service iptables start --启动文件  /etc/sysconfig/iptables # Firewall c ...

  9. jquery之隐藏div

    1.$("#demo").attr("style","display:none;");//隐藏div $("#demo" ...

  10. C#-高血压生活习惯数据模拟

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace test ...