IDENTIFICATION DIVISION.
PROGRAM-ID. 165A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(10).
01 K          PIC 9(4).
01 A          PIC 9(4).
01 B          PIC 9(4).
01 S1         PIC 9(4).
01 S2         PIC 9(4).
01 A1         PIC 9(4).
01 A2         PIC 9(4).
*>
PROCEDURE DIVISION.
  ACCEPT K.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO A B.
*>
  DIVIDE A BY K GIVING S1 REMAINDER A1.
  DIVIDE B BY K GIVING S2 REMAINDER A2.
  IF ((S1 >= 1) AND (S2 > 1)) OR
     ((A1 = 0) AND (A > K))
    DISPLAY 'OK'
  ELSE
    DISPLAY 'NG'
  END-IF.
*>
  STOP RUN.
