IDENTIFICATION DIVISION.
PROGRAM-ID. 166D.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 X          PIC 9(10) COMP.
01 A          PIC S9(3) COMP.
01 B          PIC S9(3) COMP.
01 Y          PIC S9(4) COMP.
01 Z          PIC S9(4) COMP.
01 CNT        PIC 9(18) COMP.
01 OUT1       PIC ---9.
01 OUT2       PIC ---9.
*>
PROCEDURE DIVISION.
  ACCEPT X.
*>
  MOVE 0 TO Y Z.
  PERFORM VARYING A FROM 1 BY 1 UNTIL A > 3980 OR Y > 0
    PERFORM VARYING B FROM -2500 BY 1 UNTIL B > 3980 OR Y > 0  
      IF (X = (A ** 5) - (B ** 5))
         MOVE A TO Y
         MOVE B TO Z
      END-IF 
    END-PERFORM  
  END-PERFORM.  
*>
  MOVE Y TO OUT1
  MOVE Z TO OUT2
  DISPLAY FUNCTION TRIM(OUT1) ' ' FUNCTION TRIM(OUT2).
  STOP RUN.
