//C code for 106. Binary Stirling Numbers Problem code: BINSTIRL
#include <stdio.h>
int main()
{
int t, n, m;
scanf("%d", &t);
while(t--)
{
scanf("%d%d", &n, &m);
printf("%d\n", !((n-m)&((m-1)/2)));
}
return 0;
}
#include <stdio.h>
int main()
{
int t, n, m;
scanf("%d", &t);
while(t--)
{
scanf("%d%d", &n, &m);
printf("%d\n", !((n-m)&((m-1)/2)));
}
return 0;
}
could u plz explain the logic
ReplyDeletesee here : http://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind#Parity
ReplyDelete