Sunrise and Sunset

source: 14th PC Koshien, Preliminary Round

raw_problem:
Sunrise and Sunset

When the sun appears, it is called "sunrise" and when it disappears, it is called "sunset," but what is the exact time when the sun is positioned relative to the horizon?

As shown in the figure below, the sun is represented by a circle and the horizon by a straight line. The time of sunrise and sunset is the moment when the upper edge of the circle representing the sun touches the straight line representing the horizon. After the time of sunrise, the time when the upper edge of the circle is above the straight line is daytime, and the time when the circle is completely hidden below the straight line is night.

Given the height from the horizon to the center of the sun at a given time and the radius of the sun, make a program to output whether the time is "daytime," "sunrise or sunset," or "night."

Input

The input is given in the following format

<var>H</var> <var>R</var>

The input consists of one line, with an integer <var>H</var> (-1000 ≤ <var>H</var> ≤ 1000) representing the height from the horizon to the center of the sun at a given time, and an integer <var>R</var> (1 ≤ <var>R</var> ≤ 1000) representing the radius. However, <var>H</var>  is zero when the center of the sun is on the horizon, positive when it is above the horizon, and negative when it is below the horizon.

Output

Output "1" for daytime, "0" for sunrise or sunset, and "-1" for night in a line.

Sample Input 1

-3 3

Sample Output 1

0

Sample Input 2

3 3

Sample Output 2

1

Sample Input 3

-4 3

Sample Output 3

-1

solutions: ["H,R=map(int,input().split())\nprint(0 if H+R==0 else(1 if 0<=H+R else -1))\n", "def f(h,r):\n    ret = r+h\n    if ret != 0:\n        ret //= abs(ret)\n    return ret\n\ndef main():\n    h,r = map(int,input().split())\n    print(f(h,r))\n\nif __name__ == '__main__':\n    main()\n", "h, r = map(int, input().split())\nif h == -r:\n    print(0)\nelif h > -r:\n    print(1)\nelse:\n    print(-1)\n    \n", "H, R = map(int, input().split())\nif H*(-1) == R: print(0)\nelif H*(-1) > R: print(-1)\nelif H*(-1) < R: print(1)\n", "h, r = map(int, input().split())\nif h + r == 0:\n  print(0)\nelif h + r > 0:\n  print(1)\nelse:\n  print(-1)\n", "import sys\n\n# READ_FROM_FILE = True\nREAD_FROM_FILE = False\n\n\ndef main():\n    if READ_FROM_FILE:\n        f = open('test0.txt', 'r')\n    else:\n        f = sys.stdin\n\n    h, r = map(int, f.readline().split())\n    if h + r < 0:\n        print(-1)\n    elif h + r > 0:\n        print(1)\n    else:\n        print(0)\n\n    if READ_FROM_FILE:\n        f.close()\n    return\n\n\nif __name__ == '__main__':\n    main()\n\n", "h, r = map(int, input().split())\nif h >= 0:\n    print(1)\nelse:\n    if r + h > 0:\n        print(1)\n    elif r + h == 0:\n        print(0)\n    else:\n        print(-1)\n\n", "h, r = map(int, input().split())\nif h + r == 0: print(0)\nelif h + r < 0: print(-1)\nelse: print(1)\n", "h, r = [int(num) for num in input().split()]\nif h == -r:\n    print(0)\nelif h > -r:\n    print(1)\nelse:\n    print(-1)\n", "H, R = map(int, input().split())\nif H + R > 0 :\n    print(1)\nelif H + R == 0 :\n    print(0)\nelse :\n    print(-1)\n", "h,r=map(int,input().split())\nif h+r>0:\n    print(\"1\")\nelif h+r<0:\n    print(\"-1\")\nelse:\n    print(\"0\")\n", "h, r = map(int, input().split())\n\nif h+r == 0:\n    print(0)\nelif h+r > 0:\n    print(1)\nelse:\n    print(-1)\n\n", "H, R = map(int, input().split())\nif H + R < 0:\n    print(-1)\nelif H * -1 == R:\n    print(0)\nelse:\n    print(1)\n", "h, r = map(int, input().split())\nif h + r < 0:print(-1)\nelse:print(0 if h + r == 0 else 1)\n", "h,r=map(int,input().split())\nif h+r>0: print(\"1\")\nelif h+r==0: print(\"0\")\nelse: print(\"-1\")\n", "#\u6a19\u6e96\u5165\u529b\ni = sum(list(map(int,input().split())))\n\n#2\u6570\u306e\u5408\u8a08\u304c0\u306a\u30890\u8ca0\u306e\u6570\u306a\u3089-1\u6b63\u306e\u6570\u306a\u30891\u3092\u51fa\u529b\u3059\u308b\nif i == 0:print(\"0\")\nelif i > 0:print(\"1\")\nelse:print(\"-1\")\n", "h,r = map(int,input().split())\n\nif h + r == 0 :\n    print(0)\nelif h + r > 0 :\n    print(1)\nelse:\n    print(-1)\n\n", "H,r = map(int,input().split())\nif H+r == 0:\n    print('0')\nelif H+r > 0:\n    print('1')\nelse:\n    print('-1')\n", "h,r = map(int,input().split())\nif h+r == 0:\n    print(0)\nelif h+r > 0:\n    print(1)\nelse:\n    print(-1)\n\n", "h,r=map(int, input().split())\nif h+r>0:\n    print(1)\nelif h+r==0:\n    print(0)\nelse:\n    print(-1)\n\n", "a,b = map(int,input().split())\nif a+b == 0:\n    print(0)\nelif a+b > 0:\n    print(1)\nelse:\n    print(-1)\n", "H, R = map(int, input().split())\nif -H == R: print(0)\nelif -H > R: print(-1)\nelif -H < R: print(1)\n", "H, R = map(int, input().split())\n\nif H + R > 0:\n    print(1)\nelif H + R == 0:\n    print(0)\nelse:\n    print(-1)\n", "H, R = map(int, input().split())\nif H*(-1) == R: print(0)\nelif H*(-1) > R: print(-1)\nelif H*(-1) < R: print(1)\n\n", "H, R = map(int, input().split())\nA, B = H+R, 0\nif A>0:\n\tB=1\nelif A<0:\n\tB=-1\nprint(B)\n", "H, R = map(int, input().split())\nif -H == R:\n    print(0)\nelif -H < R:\n    print(1)\nelif -H > R:\n    print(-1)\n", "p = sum([ int(s) for s in input().split() ])\n  \nif p == 0:\n    print(0)\nelif p < 0:\n    print(-1)\nelse:\n    print(1)\n", "H, R = map(int, input().split())\nif H + R < 0:\n    res = -1\nelif H + R == 0:\n    res = 0\nelse:\n    res = 1\nprint(res)\n", "h, r = map(int, input().split())\nans = 1\nif h < 0 and abs(h) > r :\n    ans = -1\nelif h < 0 and abs(h) == r :\n    ans = 0\nprint(ans)\n\n\n\n", "h, r = map(int, input().split())\nif h+r == 0:\n    print(0)\nelif h+r > 0:\n    print(1)\nelse:\n    print(-1)\n", "H , R = map(int,input().split())\n\ns = H + R\n\nif s < 0:\n    print(\"-1\")\nelif s > 0:\n    print(\"1\")\nelse:\n    print(s)\n", "H, R = map(int, input().split())\n\nif H + R == 0:\n    print(0)\nelif H + R < 0:\n    print(-1)\nelif H + R > 0:\n    print(1)\n", "H, R = map(int, input().split())\nif H*(-1) == R: print(0)\nelif H*(-1) > R: print(-1)\nelif H*(-1) < R: print(1)\n\n\n", "h, r = map(int, input().split())\nif -h == r: print(0)\nelif -h > r: print(-1)\nelif -h < r:print(1)\n", "H, R = map(int, input().split())\nif H*(-1) == R: print(0)\nelif H*(-1) > R: print(-1)\nelif H*(-1) < R: print(1)\n", "H,R = map(int,input().split())\nif H*-1 == R: print(0)\nelif H*-1 < R: print(1)\nelse: print(-1)\n", "h, r = map (int, input().split())\nif h*(-1) == r: print(0)\nelif h*(-1) > r: print(-1)\nelif h*(-1) < r: print(1)\n\n\n", "H,R = map(int,input().split())\nif H +R == 0 :#\u65e5\u306e\u5165\u308a\u307e\u305f\u306f\u65e5\u306e\u51fa\u306e\u6642\n    print(0)#0\u3068\u51fa\u529b\u3059\u308b\nelif H + R > 0:#\u663c\u9593\u306e\u6642\n    print(1)\nelif H +R < 0:#\u591c\u9593\u306e\u6642\n    print(-1)\n", "a,b = map(int,input().split())\nif a + b > 0:\n    print(1)\nelif a + b == 0:\n    print(0)\nelse:\n    print(-1)\n", "H,R = map(int,input().split())\nif  -1 * R == H:\n  a = 0\nelif H>=0:\n  a = 1\nelse:\n  a = -1\nprint(a)\n", "h,r=map(int,input().split())\nif (h+r==0):\n    print(0)\nelif(h+r>0):\n    print(1)\nelse:\n    print(-1)\n", "\"\"\"python\"\"\"\n\nb = input().split()\nH = int(b[0])       \nR = int(b[1])     \n\nif (H<0 and (-H==R)):\n    print(\"0\")\nelif H<0 and H<R:\n    print(\"-1\")\nelif H<0 and H>R:\n    print(\"1\")\nelse:\n    print(\"1\")\n\n", "H,R = map(int,input().split())\nif -H < R:\n    print(1)\nelif -H==R:\n    print(0)\nelif -H > R:\n    print(-1)        \n   \n         \n", "H,R = map(int,input().split())\nif(-H==R):\n    print(0)\nelif(-H>R):\n    print(\"-1\")\nelif(-H<R):\n    print(\"1\")\n", "H,R = map(int, input().split())\nif H < 0:\n    if H + R < 0:\n        print(-1)\n    elif H + R == 0:\n        print(0)\n    else:\n        print(1)\nelse:\n    print(1)\n\n\n", "R, H = map(int,input().split())\nif H + R > 0:\n    print(1)\nelif H + R < 0:\n    print(-1)\nelse:\n    print(0)\n", "H , R = map(int, input().split())\nif  -H == R : print(0)\nelif -H > R : print(-1)\nelif -H < R : print(1)\n\n", "H, R = map(int, input().split())\nif H + R == 0: #\u65e5\u306e\u51fa\u30fb\u65e5\u306e\u5165\u308a\n    print(0)\nelif R + H > 0: #\u663c\u9593\n    print(1)    #\u591c\u9593\nelse:\n    print(-1)\n\n", "H,R = map(int,input().split())\nif H+R==0:\n    print(0)\nelif H+R>0:\n    print(1)\nelse:\n    print(-1)\n", "H,R = map(int,input().split())\nif H == 0:\n    print(1)\nelif H > 0:\n        print(1)\nelse:\n    if H + R == 0:\n        print(0)\n    else:\n        print(-1)\n\n", "H, R = map(int, input().split())\n\n# \u300c\u592a\u967d\u306e\u9ad8\u3055\uff0b\u592a\u967d\u306e\u534a\u5f84\u300d\u304c\n#\u3000 0\u306a\u3089\u300c0\u300d(\u65e5\u306e\u51fa\u307e\u305f\u306f\u65e5\u306e\u5165\u308a)\u3001\u6b63\u306a\u3089\u300c1\u300d(\u663c\u9593)\u3001\u8ca0\u306a\u3089\u300c-1\u300d(\u591c\u9593)\n\nif H+R==0:\n    print(0)\nelif H+R>0:\n    print(1)\nelse:\n    print(-1)\n", "h, r = map(int,input().split())\n\nif h+r > 0:\n    print(\"1\")\nelif h+r < 0:\n    print(\"-1\")\nelse:\n    print(\"0\")\n\n", "H, R = map(int,input().split())\nif H* -1 == R:\n    print(0)\nelif H* -1 < R:\n    print(1)\nelse:\n    print(-1)\n", "h,r=map(int,input().split())\nif (h+r==0):\n    print(0)\nelif(h+r>0):\n    print(1)\nelse:\n    print(-1)\n", "H, R = map(int, input().split())\nif   -H == R: print(0)\nelif -H > R: print(-1)\nelif -H < R: print(1)\n", "#\u9ad8\u3055\u3068\u534a\u5f84\u3092\u8aad\u307f\u8fbc\u3080\nH,R = map(int,input().split())\n\nif H * (-1) == R:\n    print(0)\nelif H * (-1) > R:\n    print(-1)\nelif H * (-1) < R:\n    print(1)\n\n", "h,r=map(int,input().split())\nif h>=0:\n    print(1)\nelif h+r==0:\n    print(0)\nelse:\n    print(-1)\n", "H,R =map (int,input().split())\nif -H == R: print(0)\nelif -H > R: print(-1)\nelif -H < R: print(1)\n", "H,R = map(int,input().split())\nif -H == R:\n    print(0)\nelif -H < R:\n    print(1)\nelse:\n    print(-1)\n", "H,R = map(int,input().split())\n\nif H>=0:\n    print(1)\nelif  H<0:\n    if H+R>0:\n        print(1)\n    elif H+R==0:\n        print(0)\n    else:\n        print(-1)\n        \n\n", "h,r = map(int,input().split())\nif(0==h+r):\n    print(0)\nelif(0<h+r):\n    print(1)\nelse:\n    print(-1)\n", "a,b = (int(x) for x in input().split())\nif a+b == 0 :\n    print(\"0\")\nelif a+b > 0 :\n    print(\"1\")\nelse :\n    print(\"-1\")\n", "H,R = list(map(int, input().split()))\n\nif H+R==0:\n    ans = 0\nelif H+R>=1:\n    ans = 1\nelse:\n    ans = -1\n\nprint(ans)\n", "h, r = list(map(int, input().split()))\nprint(int((h+r>0)-(h+r<0)))\n", "h,r = map(int, input().split())\nif -h == r: print(0)\nelif -h > r: print(-1)\nelif -h < r: print(1)\n", "H, R=map(int,input().split())\nheight=H + R\nif height >0:\n  print(1)\nelif height==0:\n  print(0)\nelse:\n  print(-1)\n", "h,r=map(int,input().split())\nif h<0:\n    print(-1 if h+r<0 else 0 if h+r==0 else 1)\nelse:\n    print(1)\n", "h, r = map(int, input().split())\nif h >= r or h >= 0: print(1)\nelse: print(0 if h + r == 0 else -1)\n", "# aizu 4.4.2 \u65e5\u306e\u51fa\u3068\u65e5\u306e\u5165\u308a\n\nheight,radius=map(int,input().split())\n\nif height<0:\n    if abs(height)==radius:\n        result=0\n    elif abs(height)<radius:\n        result=1\n    else:\n        result=-1\nelse:\n    result=1\n\nprint(result)\n", "H, R = map( int, input().split() )\n\nans = -1\nif H + R == 0:\n    ans = 0\nelif H + R > 0:\n    ans = 1\n\nprint( ans )\n\n\n", "H,R=map(int,input().split())\nprint(0 if H+R==0 else(1 if 0<=H+R else -1))\n"]

source: aizu

question:
Sunrise and Sunset

When the sun appears, it is called "sunrise" and when it disappears, it is called "sunset," but what is the exact time when the sun is positioned relative to the horizon?

As shown in the figure below, the sun is represented by a circle and the horizon by a straight line. The time of sunrise and sunset is the moment when the upper edge of the circle representing the sun touches the straight line representing the horizon. After the time of sunrise, the time when the upper edge of the circle is above the straight line is daytime, and the time when the circle is completely hidden below the straight line is night.

![image](1.png)

Given the height from the horizon to the center of the sun at a given time and the radius of the sun, make a program to output whether the time is "daytime," "sunrise or sunset," or "night."

Input

The input is given in the following format

$H$ $R$

The input consists of one line, with an integer $H$ (-1000 ≤ $H$ ≤ 1000) representing the height from the horizon to the center of the sun at a given time, and an integer $R$ (1 ≤ $R$ ≤ 1000) representing the radius. However, $H$  is zero when the center of the sun is on the horizon, positive when it is above the horizon, and negative when it is below the horizon.

Output

Output "1" for daytime, "0" for sunrise or sunset, and "-1" for night in a line.

Sample Input 1

-3 3

Sample Output 1

0

![image](2.png)

Sample Input 2

3 3

Sample Output 2

1

![image](3.png)

Sample Input 3

-4 3

Sample Output 3

-1

![image](4.png)

image_tags:
Others
2D Geometry
2D Geometry
2D Geometry

data_split: test