#include cmath
#include cstdio
#include iostream
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#define For(i,a,b) for (long i(a),_b(b); i = _b; ++i)
char buf[1024*1024];
bool isEven(long a,long b)
{ bool result=0;
if(b%2==0)
result=0;
else
I found one mistake : If b PD, you are returning 0. Why is that?
Lets say you have 4 switches, PD = 16. If b = 15, the answer should be ON.
Other than that, there are many ways you can improve your code.
1.
dont use double. It will remove accuracy in many places. 10^8 will come
within 4 bytes