The question is hard to understand. Understand this sentence: Pig jumps at will, and people can choose. Make sure that it is just a pig when jumping off the river.
# Include <iostream> # include <stdio. h> using namespace STD; int n, m; char s [51000]; bool find (int x, int y, int cul) {int K = 1, temp; if (x> Y) {int tempx = x-K * Y; while (tempx> = 0) {temp = (tempx * cul + y ); if (s [temp] = 'P') return true; k ++; tempx = x-K * Y;} else {int Tempy = Y-K * X; while (Tempy> = 0) {temp = (x * cul + Tempy); If (s [temp] = 'P') return true; k ++; tempy = Y-K * X;} return false;} int main () {int CA = 0; while (scanf ("% d", & N, & M )! = EOF) {printf ("case # % d: \ n", ++ CA); int I, j, k = m + 1; for (I = 0; I <= m; I ++) s [I] = 'H'; for (I = 1; I <= N; I ++) s [I * k] = 'H'; for (I = 1; I <= N; I ++) {for (j = 1; j <= m; j ++) {int temp = I * k + J; If (find (I, j, k) s [temp] = 'H '; else s [temp] = 'P'; printf ("% C", s [temp]);} printf ("\ n") ;}} return 0 ;}