|
|
back to boardTest case 5 Please help me .this code failed at test case 5 #include <stdio.h> int main() { int n,k; scanf ("%d\n%d" ,&n,&k); int l, pos; l = n % 2 ;
if ( l != 0 || n < 1 || k < 1 || k > n || n > 50 ) { printf("invalid input"); } else { if (n != 2 ) { if ( k <= n/2 ) { pos = n/2 - k ; printf("%d", pos); } else { pos = k - ((n/2) + 1 ); printf("%d", pos); } } } if ( n == 2 ) { pos = 0; printf("%d", pos); } return 0; }
|
|
|