http://codeforces.com/problemset/problem/279/A

题意 :就是给你一个螺旋形的图,然后给你一个点,问从(0,0)点到这个点需要转几次弯,当然,是按着这个螺旋图走的。

思路 :好吧,这个题是需要找一下规律的。。。。。。

这个图主要注意的是我标了坐标的那四个点,那是每个螺旋的最右下方的点,然后那些带圆圈的是那个点应该转的次数,在(1,0)点转0次,在(2,-1)点转4次,在(3,-2)点需要转8次。所以,坐标中绝对值最大的减掉1再乘上4,而别的边就好说了,和它同一横坐标的次数相同,同一纵坐标的,次数加1,然后是次数加2,次数加3,次数加4.。。。。。。。。。。。。。

#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std; int main()
{
int x,y;
while(~scanf("%d %d",&x,&y))
{
if(x == && y == )
{
printf("0\n");
continue;
}
int maxx = max(abs(x),abs(y));
int cnt = (maxx-)*;
if((x == maxx||x == maxx-) && y == -maxx)
printf("%d\n",cnt);
else if(x == maxx && y >= -maxx && y <= maxx)
printf("%d\n",cnt+);
else if(x >= -maxx && x <= maxx && y == maxx)
printf("%d\n",cnt+);
else if(x == -maxx && y >= -maxx && y <= maxx)
printf("%d\n",cnt+);
else if(x >= -maxx && x <= maxx && y == -maxx)
printf("%d\n",cnt+);
}
return ;
}

CF 279A. Point on Spiral的更多相关文章

  1. Pramp mock interview (4th practice): Matrix Spiral Print

    March 16, 2016 Problem statement:Given a 2D array (matrix) named M, print all items of M in a spiral ...

  2. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  3. [LeetCode] Spiral Matrix II 螺旋矩阵之二

    Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For ...

  4. [LeetCode] Spiral Matrix 螺旋矩阵

    Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or ...

  5. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  6. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  7. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  8. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  9. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

随机推荐

  1. JAXB - Annotations, Controlling Element Selection: XmlAccessorType, XmlTransient

    If JAXB binds a class to XML, then, by default, all public members will be bound, i.e., public gette ...

  2. Spark技术内幕:Client,Master和Worker 通信源码解析

    http://blog.csdn.net/anzhsoft/article/details/30802603 Spark的Cluster Manager可以有几种部署模式: Standlone Mes ...

  3. ubuntu 16.04 chrome flash player 过期

    今天手贱更新了系统,发现chrome flash插件过期了 解决方法: 使用全局代理打开 chrome $: google-chrome --proxy-server="socks5://1 ...

  4. 编译个性化的openwrt固件

    基本流程是:下载openwrt源码(推荐attitude adjustment版本).执行feeds更新.make menuconfig(通过配置feed.conf.default和menuconfi ...

  5. 在页面生命周期执行时 Page 对象在 SaveState 阶段都发生了什么事?

    先看下 SaveViewState 的源码: // Answer any state this control or its descendants want to save on freeze. / ...

  6. 快速登录IRC网络聊天室

    随便起个NickName,进行人机验证,然后点击Connect进去就可以咯.

  7. Git和CocoaPods的简单使用

    Git是一款免费.开源的分布式版本控制系统,还有一种SVN的开源的集中式版本控制系统.分布式相比于集中式的最大区别在于开发者可以提交到本地,每个开发者通过克隆(git clone),在本地机器上拷贝一 ...

  8. SQL Constraint/Index

    1.SQL Constraint Integrity Constraints are used to apply business rules for the database tables. The ...

  9. Linux之在CentOS上一次艰难的木马查杀过程

    今天朋友说他一台要准备上线的生产服务器被挂马,特征ps命令找不到进程,top能看到负载最高的一个程序是一个随机的10位字母的东西,kill掉之后自动再次出现一个随机10位字母的进程. 我让他关闭这个机 ...

  10. sql server 2008数据复制方法

    发布订阅份为两个步骤:1.发布.2.订阅.首先在数据源数据库服务器上对需要同步的数据进行发布,然后在目标数据库服务器上对上述发布进行订阅.发布可以发布一张表的部分数据,也可以对整张表进行发布.下面分别 ...