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. ubuntu忘记密码

    Do these two things just to make sure: mount -o remount,rw / This first part remounts the root parti ...

  2. VC6项目移植到VS2008的若干问题——好的代码,从我做起,从如今做起。

    近期,有个项目开发,须要用到曾经项目的代码,只是曾经项目都是VC6下编译通过的,在VS2008下不一定编译通过,能编译通过也不一定能链接成功.以下总结一下我在一个VC6项目移植到VS2008中遇到的一 ...

  3. Android 开源项目android-open-project解析之(三) ScrollView,TimeView,TipView,FlipView

    九.ScrollView Discrollview 支持滚动时Item淡入淡出,平移,缩放效果的ScrollView 项目地址:https://github.com/flavienlaurent/di ...

  4. 深入浅出hive-hive简介

    1. 什么是hive  •Hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供类SQL查询功能. •本质是将HQL转换为MapReduce程序  2. 为什么 ...

  5. Reso | Noise 网易云音乐插件

    源码地址:https://github.com/Simpleyyt/noise-neteasemusic安装方法:sudo add-apt-repository ppa:simpleyyt/ppasu ...

  6. RESTEasy + JBOSS 7 Hello world application---reference

    RESTEasy is JBOSS provided implementation of JAX-RS specification for building RESTful Web Services  ...

  7. JAVA IDE基本操作常识

    快捷键: Ctrl+/   选中区单行注释和 取消 选中区单行注释和 Alt + / 代码辅助 shift + Ctrl +/ 选中区多行注释 shift + Ctrl +\ 取消选中区多行注释 Ct ...

  8. Android(java)学习笔记219:开发一个多界面的应用程序之两种意图

    1.两种意图: (1)显式意图: 在代码里面用intent设置要开启Activity的字节码.class文件: (2)隐式意图: Android(java)学习笔记218:开发一个多界面的应用程序之人 ...

  9. python 全栈开发之路 day1

    python 全栈开发之路 day1   本节内容 计算机发展介绍 计算机硬件组成 计算机基本原理 计算机 计算机(computer)俗称电脑,是一种用于高速计算的电子计算机器,可以进行数值计算,又可 ...

  10. Template Method 模板方法

      简介 定义一个操作中的算法的骨架,而将一些步骤延迟到子类中. 模板方法使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤的细节 抽象模板AbstractClass的方法分为两类: 基本 ...