题目描述
You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.
Constraints
a and b are integers.
−109≤a≤b≤109
Partial Score
In test cases worth 100 points, −10≤a≤b≤10.
Constraints
a and b are integers.
−109≤a≤b≤109
Partial Score
In test cases worth 100 points, −10≤a≤b≤10.
输入
The input is given from Standard Input in the following format:
a b
a b
输出
If the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.
样例输入
1 3
样例输出
Positive
提示
1×2×3=6 is positive.
不知道该这么说,也是一道简单题。。。就对a,b进行判断,如果a<=0&&b>=0,从a到b的数乘积一定为0,直接输出Zero;否则就判断a<=0,并用b减去a,判断能否被2整除,能则输出Positive,不能则输出Negative;再否则就直接输出Positive。
以下贴上代码:
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
{
if(a<=0&&b>=0)
cout<<"Zero"<<endl;
else if(a<0)
{
int key=b-a;
if(key%2!=0)
cout<<"Positive"<<endl;
else
cout<<"Negative"<<endl;
}
else
cout<<"Positive"<<endl;
}
}