The variable will be used to count the number of satisfied conditions. Initially, it is assigned a value of .
If the number is even, increment by ;
If the number is negative and divisible by three, also increment by ;
If flag = 1, exactly one condition is satisfied, so print "YES". Otherwise, print "NO".
Example
Let n = 22. The number is even. It is not negative and divisible by . Thus, only one condition is satisfied. The answer is "YES".
Algorithm implementation
Read the input number .
scanf("%d", &n);Check two conditions. If a condition is satisfied, increment the value of the variable by .
flag = 0;
if (n % 2 == 0) flag++;
if (n < 0 && n % 3 == 0) flag++;Based on the value of , print the result.
if (flag == 1) puts("YES");
else puts("NO");Python implementation
Read the input number .
n = int(input())Check two conditions. If a condition is satisfied, increment the value of the variable by .
flag = 0
if n % 2 == 0:
flag += 1
if n < 0 and n % 3 == 0:
flag += 1Based on the value of , print the result.
if flag == 1:
print("YES")
else:
print("NO")