h2. Exemplu
table(example). |_. jupanul.in |_. jupanul.out |
| 6 2
| 6 16
| 6 3
| 6 16 38
|
table(example). |_. jupanul.in |_. jupanul.out |
| 12152 8
| 12152 27468 57294 111704 207030 369846 642894 1093344
|
|
h3. Explicaţie
Intr-un termen
* [6], cost=gcd([6])=6
Deci $f(6,1)=6$
* $[6]$
In $2$ termeni
* [1,6], cost=gcd([1]) + gcd([1,6])=1+1=2
* [6,1], cost=gcd([6]) + gcd([6,1])=6+1=7
* [2,3], cost=gcd([2]) + gcd([2,3])=2+1=3
* [3,2], cost=gcd([3]) + gcd([3,2])=3+1=4
Deci $f(6,2)=2+7+3+4=16$
* $[1, 6]$
* $[6, 1]$
* $[2, 3]$
* $[3, 2]$
In $3$ termeni
* $[1, 1, 6]$
* $[1, 2, 3]$
* $[1, 3, 2]$
* $[1, 6, 1]$
* $[2, 1, 3]$
* $[2, 3, 1]$
* $[3, 1, 2]$
* $[3, 2, 1]$
* $[6, 1, 1]$
== include(page="template/taskfooter" task_id="jupanul") ==