Start: Jul, 01, 2019 08:30:00
2019年度暑期短学期第四天
End: Jul, 01, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: G
Result: Accepted
Time: 3ms
Memory: 1120kB
Author: 2017211401036
In contest: 1277

/*首先看a:如果a>0,将b改成自身的相反数;否则b的值乘上2。然后看b(注意,这里b可能已经在上一步被改动过了),
如果b的绝对值是奇数,将a的正负号改为与b相同;如果b的绝对值是偶数,将a的正负号改为与b相反,求最后a-b的结果。

Input
两个整数,a和b

Output
输出计算结果

Samples
input:
1 -1
output:
0
*/
#include<stdio.h>
#include<math.h> 
int main()
{
	int a,b,c;
	scanf("%d%d",&a,&b);
	if(a>0)
	b=-b; 
	else
	b=2*b;
	
	if(abs(b)%2==1) 
	 {
	 if(a>0&&b<0||a<0&&b>0)
	 a=-a; 
	 } 
	else
	{
	if(a>0&&b>0||a<0&&b<0)
	 a=-a;
	} 
printf("%d",a-b); 
	return 0; 
}