AMSGAME2(Subtraction Problem 2 from May-Cook Off 13) Help

Can anyone explain me what this user has done for solving the problem ??
its a java solution !

Link to Java Solution

This program uses dynamic programming approach to solve a program. In hm TreeMap he stores gcd as key and the number of sequences that gives this gcd as value. So in each iteration he reads an integer and scans through the hm TreeMap and increases the count of gcd’s if this integer was also there in the sequence i,e he will increase the number of value of gcd tht occur with the old gcd in map and the current number. At last he will increase the value with the current number as gcd coz this number alone can b in the sequence. At last we want the number of sequences wich gives the gcd of 1.
so he prints the value in hm map with key 1.

I forgot to add this.
No of sequences of gcd(number, a vaule in hm ) = No of sequences of gcd(number, a vaule in hm )

  • No of sequences of a vaule in hm