Back
Close

Sign of Product

Statement

 Goal

Given two integers a and b, answer the sign of the product of a, a+1, ..., b.
Input
Two integers a and b separated by space.
Output
If the product is positive, output 1. If it is zero, output 0. If it is negative, output -1.
Constraints
-10^10 ≤ ab ≤ 10^10
Example
Input
3 5
Output
1

Game modes
FastestShortest

Test cases
Example Test
Input
3 5
Output
1

Validator 1 Validator
Input
8 13
Output
1

1,1,1 Test
Input
2 8
Output
1

Validator 2 Validator
Input
2833 4792
Output
1

0,1,0 Test
Input
0 7
Output
0

Validator 3 Validator
Input
0 38727
Output
0

0,0,0 Test
Input
0 0
Output
0

Validator 4 Validator
Input
0 0
Output
0

-1,1,0 Test
Input
-1 3
Output
0

Validator 5 Validator
Input
-683215 58743823
Output
0

-1,0,0 Test
Input
-9 0
Output
0

Validator 6 Validator
Input
-368921 0
Output
0

-1,-1,1 Test
Input
-9 -6
Output
1

Validator 7 Validator
Input
-321687 -321044
Output
1

-1,-1,-1 Test
Input
-4 -2
Output
-1

Validator 8 Validator
Input
-43 -21
Output
-1

Large Both Positive Test
Input
1 10000000000
Output
1

Validator 9 Validator
Input
7 9994992999
Output
1

Large Both Negative Test
Input
-10000000000 -1
Output
1

Validator 10 Validator
Input
-9997491183 -381
Output
-1

Solution language

Solution

Stub generator input
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants