3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); $bills = [2, 5, 20, 50]; $count = [3, 1, 4, 1]; $amount = 66; define('BIG_INT', 1000000000); $F = []; $F[0] = 0; $B[0] = [0, 0, 0, 0]; for ($m = 1; $m <= $amount; $m++) { $F[$m] = BIG_INT; foreach ($bills as $key) { $B[$m][] = 0; } for ($i = 0; $i < count($bills); $i++) { if ($m >= $bills[$i] && $F[$m - $bills[$i]] + 1 < $F[$m] && $count[$i] != 0) { if ($B[$m - $bills[$i]][$i] + 1 > $count[$i]) { continue; } else { $B[$m] = $B[$m - $bills[$i]]; $F[$m] = $F[$m - $bills[$i]] + 1; $B[$m][$i]++; } } } } if (array_sum($B[$amount]) > 0) { echo "Выдать сумму $amount можно так:\n"; foreach ($bills as $key => $value) { if ($B[$amount][$key] != 0) { $sum = $B[$amount][$key] * $value; echo "{$B[$amount][$key]} * $value = " . $sum . "\n"; } } } else { echo "Сумму нельзя выдать\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 17
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 108
Branch analysis from position: 81
2 jumps found. (Code = 77) Position 1 = 86, Position 2 = 106
Branch analysis from position: 86
2 jumps found. (Code = 78) Position 1 = 87, Position 2 = 106
Branch analysis from position: 87
2 jumps found. (Code = 43) Position 1 = 92, Position 2 = 105
Branch analysis from position: 92
1 jumps found. (Code = 42) Position 1 = 86
Branch analysis from position: 86
Branch analysis from position: 105
Branch analysis from position: 106
1 jumps found. (Code = 42) Position 1 = 109
Branch analysis from position: 109
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 106
Branch analysis from position: 108
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 29
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 17
Branch analysis from position: 75
Branch analysis from position: 17
Branch analysis from position: 29
2 jumps found. (Code = 46) Position 1 = 32, Position 2 = 39
Branch analysis from position: 32
2 jumps found. (Code = 46) Position 1 = 40, Position 2 = 43
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 68
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 54
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 29
Branch analysis from position: 72
Branch analysis from position: 29
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 29
Branch analysis from position: 72
Branch analysis from position: 29
Branch analysis from position: 68
Branch analysis from position: 43
Branch analysis from position: 39
Branch analysis from position: 26
filename:       /in/riYAq
function name:  (null)
number of ops:  110
compiled vars:  !0 = $bills, !1 = $count, !2 = $amount, !3 = $F, !4 = $B, !5 = $m, !6 = $key, !7 = $i, !8 = $value, !9 = $sum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 -1
          2        DO_ICALL                                                 
    5     3        ASSIGN                                                   !0, <array>
    6     4        ASSIGN                                                   !1, <array>
    8     5        ASSIGN                                                   !2, 66
   10     6        INIT_FCALL                                               'define'
          7        SEND_VAL                                                 'BIG_INT'
          8        SEND_VAL                                                 1000000000
          9        DO_ICALL                                                 
   12    10        ASSIGN                                                   !3, <array>
   14    11        ASSIGN_DIM                                               !3, 0
         12        OP_DATA                                                  0
   15    13        ASSIGN_DIM                                               !4, 0
         14        OP_DATA                                                  <array>
   17    15        ASSIGN                                                   !5, 1
         16      > JMP                                                      ->73
   18    17    >   FETCH_CONSTANT                                   ~20     'BIG_INT'
         18        ASSIGN_DIM                                               !3, !5
         19        OP_DATA                                                  ~20
   19    20      > FE_RESET_R                                       $21     !0, ->26
         21    > > FE_FETCH_R                                               $21, !6, ->26
   20    22    >   FETCH_DIM_W                                      $22     !4, !5
         23        ASSIGN_DIM                                               $22
         24        OP_DATA                                                  0
   19    25      > JMP                                                      ->21
         26    >   FE_FREE                                                  $21
   22    27        ASSIGN                                                   !7, 0
         28      > JMP                                                      ->69
   23    29    >   FETCH_DIM_R                                      ~25     !0, !7
         30        IS_SMALLER_OR_EQUAL                              ~26     ~25, !5
         31      > JMPZ_EX                                          ~26     ~26, ->39
         32    >   FETCH_DIM_R                                      ~27     !0, !7
         33        SUB                                              ~28     !5, ~27
         34        FETCH_DIM_R                                      ~29     !3, ~28
         35        ADD                                              ~30     ~29, 1
         36        FETCH_DIM_R                                      ~31     !3, !5
         37        IS_SMALLER                                       ~32     ~30, ~31
         38        BOOL                                             ~26     ~32
         39    > > JMPZ_EX                                          ~26     ~26, ->43
         40    >   FETCH_DIM_R                                      ~33     !1, !7
         41        IS_NOT_EQUAL                                     ~34     ~33, 0
         42        BOOL                                             ~26     ~34
         43    > > JMPZ                                                     ~26, ->68
   24    44    >   FETCH_DIM_R                                      ~35     !0, !7
         45        SUB                                              ~36     !5, ~35
         46        FETCH_DIM_R                                      ~37     !4, ~36
         47        FETCH_DIM_R                                      ~38     ~37, !7
         48        ADD                                              ~39     ~38, 1
         49        FETCH_DIM_R                                      ~40     !1, !7
         50        IS_SMALLER                                               ~40, ~39
         51      > JMPZ                                                     ~41, ->54
   25    52    > > JMP                                                      ->68
   24    53*       JMP                                                      ->68
   27    54    >   FETCH_DIM_R                                      ~43     !0, !7
         55        SUB                                              ~44     !5, ~43
         56        FETCH_DIM_R                                      ~45     !4, ~44
         57        ASSIGN_DIM                                               !4, !5
         58        OP_DATA                                                  ~45
   28    59        FETCH_DIM_R                                      ~47     !0, !7
         60        SUB                                              ~48     !5, ~47
         61        FETCH_DIM_R                                      ~49     !3, ~48
         62        ADD                                              ~50     ~49, 1
         63        ASSIGN_DIM                                               !3, !5
         64        OP_DATA                                                  ~50
   29    65        FETCH_DIM_RW                                     $51     !4, !5
         66        FETCH_DIM_RW                                     $52     $51, !7
         67        PRE_INC                                                  $52
   22    68    >   PRE_INC                                                  !7
         69    >   COUNT                                            ~55     !0
         70        IS_SMALLER                                               !7, ~55
         71      > JMPNZ                                                    ~56, ->29
   17    72    >   PRE_INC                                                  !5
         73    >   IS_SMALLER_OR_EQUAL                                      !5, !2
         74      > JMPNZ                                                    ~58, ->17
   35    75    >   INIT_FCALL                                               'array_sum'
         76        FETCH_DIM_R                                      ~59     !4, !2
         77        SEND_VAL                                                 ~59
         78        DO_ICALL                                         $60     
         79        IS_SMALLER                                               0, $60
         80      > JMPZ                                                     ~61, ->108
   36    81    >   ROPE_INIT                                     3  ~63     '%D0%92%D1%8B%D0%B4%D0%B0%D1%82%D1%8C+%D1%81%D1%83%D0%BC%D0%BC%D1%83+'
         82        ROPE_ADD                                      1  ~63     ~63, !2
         83        ROPE_END                                      2  ~62     ~63, '+%D0%BC%D0%BE%D0%B6%D0%BD%D0%BE+%D1%82%D0%B0%D0%BA%3A%0A'
         84        ECHO                                                     ~62
   37    85      > FE_RESET_R                                       $65     !0, ->106
         86    > > FE_FETCH_R                                       ~66     $65, !8, ->106
         87    >   ASSIGN                                                   !6, ~66
   38    88        FETCH_DIM_R                                      ~68     !4, !2
         89        FETCH_DIM_R                                      ~69     ~68, !6
         90        IS_NOT_EQUAL                                             ~69, 0
         91      > JMPZ                                                     ~70, ->105
   39    92    >   FETCH_DIM_R                                      ~71     !4, !2
         93        FETCH_DIM_R                                      ~72     ~71, !6
         94        MUL                                              ~73     !8, ~72
         95        ASSIGN                                                   !9, ~73
   40    96        FETCH_DIM_R                                      ~75     !4, !2
         97        FETCH_DIM_R                                      ~76     ~75, !6
         98        ROPE_INIT                                     4  ~78     ~76
         99        ROPE_ADD                                      1  ~78     ~78, '+%2A+'
        100        ROPE_ADD                                      2  ~78     ~78, !8
        101        ROPE_END                                      3  ~77     ~78, '+%3D+'
        102        CONCAT                                           ~80     ~77, !9
        103        CONCAT                                           ~81     ~80, '%0A'
        104        ECHO                                                     ~81
   37   105    > > JMP                                                      ->86
        106    >   FE_FREE                                                  $65
   35   107      > JMP                                                      ->109
   44   108    >   ECHO                                                     '%D0%A1%D1%83%D0%BC%D0%BC%D1%83+%D0%BD%D0%B5%D0%BB%D1%8C%D0%B7%D1%8F+%D0%B2%D1%8B%D0%B4%D0%B0%D1%82%D1%8C%0A'
   45   109    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.42 ms | 1015 KiB | 16 Q