http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1615

题意:

思路:
一开始是觉得一旦超过了终点,中间某个地方往相反地方跳就可以了,后来发现只有超过距离是偶数时才行,奇数是不行的。那么奇数怎么办呢,继续往前跳,直到间距为偶数即可。

 #include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
const int INF = 0x3f3f3f3f;
const int maxn = + ; ll x; int main()
{
//freopen("in.txt","r",stdin);
while(~scanf("%lld",&x))
{
if(x<) x=-x;
ll sum = ;
int i=;
for(;;i++)
{
sum+=i;
if(sum>=x) break;
}
if(sum>x && ((sum-x)&))
{
while((sum-x)&) sum+=++i;
}
cout<<i<<endl;
}
return ;
}

51nod 1615 跳跃的杰克的更多相关文章

  1. 51nod百度之星2016练习赛

    今天看了看51nod发现有这样一个练习赛,就做了做.因为实力太弱想不出E题,各位神犇勿D. (5.26UPD:E题想粗来了) A 区间交 不难发现若干线段[li,ri]的交就是[max(li),min ...

  2. 51nod 最近刷题 简要题解

    51nod 1564 由于数据是随机的,可以证明,对于每一个数,向左或右找比它小的数,长度是logn级别的 考虑枚举最大值 注意,对于每一个最大值,如果直接用2个循环枚举左右端点的话,理论是lognl ...

  3. 51NOD 1709:复杂度分析——题解

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1709 (我什么时候看到二进制贡献才能条件反射想到按位处理贡献呢……) 参 ...

  4. 跳跃的舞者,舞蹈链(Dancing Links)算法——求解精确覆盖问题

    精确覆盖问题的定义:给定一个由0-1组成的矩阵,是否能找到一个行的集合,使得集合中每一列都恰好包含一个1 例如:如下的矩阵 就包含了这样一个集合(第1.4.5行) 如何利用给定的矩阵求出相应的行的集合 ...

  5. 【51Nod 1244】莫比乌斯函数之和

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1244 模板题... 杜教筛和基于质因子分解的筛法都写了一下模板. 杜教筛 ...

  6. [LeetCode] Jump Game II 跳跃游戏之二

    Given an array of non-negative integers, you are initially positioned at the first index of the arra ...

  7. 51Nod 1268 和为K的组合

    51Nod  1268  和为K的组合 1268 和为K的组合 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 给出N个正整数组成的数组A,求能否从中选出若干个,使 ...

  8. 51Nod 1428 活动安排问题

    51Nod   1428  活动安排问题 Link: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1428 1428 活 ...

  9. 51Nod 1278 相离的圆

    51Nod 1278 相离的圆 Link: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1278 1278 相离的圆 基 ...

随机推荐

  1. arcgis desktop 地理编码服务发布

    1.创建地址定位器 2.创建复合地址定位器 3.鼠标右键,共享为,地理编码服务.

  2. Qt 之 pro 配置详解

    原文地址:https://blog.csdn.net/liang19890820/article/details/51774724 简述 使用Qt的时候,我们经常会对pro进行一系列繁琐的配置,为方便 ...

  3. POJ 3320 Jessica's Reading Problem (尺取法)

    Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is co ...

  4. docker local registry server gave HTTP response to HTTPS client

    server gave HTTP response to HTTPS client报错是在insecure_registry中加入了http前缀,如果本地registry不是https的 就不要加任何 ...

  5. reids非关系性数据库

     1.Redis环境配置 下载安装地址: https://github.com/MicrosoftArchive/redis/releases 解压文件到指定的目录,D:\ChromeCoreDown ...

  6. JavaScript快速总结之一

    js格式和位置: <!--js内容可以在head中,也可以在body中,不同位置执行顺序会有区别 ,另外也可以单独放到一个js文件中,这样方便维护和修改,而且,可以加快html页面的加载速度.- ...

  7. django 模型类的常见字段约束,以及filter 过滤和查询

    null 不设置时默认设置为False.设置为True时,数据库表字段中将存入NULL的记录. null和blank组合使用,null=True,blank=True,表示该字段可以为空 blank ...

  8. yum指定安装目录

    纯粹做笔记 yum -c /etc/yum.conf --installroot=/opt/test/ --releasever=/ install lrzsz

  9. VIM自动补全Python代码

    pydiction插件 https://codeload.github.com/rkulla/pydiction/zip/master 新建bundle文件夹 mkdir ~/.vim/bundle ...

  10. GDI的 点 线 面 双缓冲 位图的绘制

    1.输出文本 // 输出文本 ,,)); //设置字体颜色,但最后都要返回原来的字体格式 COLORREF clrBackColor = SetBkColor(hDC, RGB(,,)); //设置背 ...