Here's a Python program that can determine the number of different variants of gifts weighing exactly `w` grams:

```
candy = x
mandarin = y
cookie = z

def count_gifts(w):
    count = 0
    for i in range(w // candy + 1):
        for j in range(w // mandarin + 1):
            for k in range(w // cookie + 1):
                if i * candy + j * mandarin + k * cookie == w:
                    count += 1
    return count

# Example usage
gift_weight = 100
num_gifts = count_gifts(gift_weight)
print(f"There are {num_gifts} different variants of gifts that weigh exactly {gift_weight} grams.")
```

To use this program, simply change the values of `x`, `y`, and `z` to the weights of your candies, mandarins, and cookies, respectively. Then call the `count_gifts` function with the desired weight of the gift, and it will return the number of different gift combinations that weigh exactly `w` grams.
La caramella pesa &quot;x&quot; grammi, il mandarino pesa &quot;y&quot; grammi, il biscotto pesa &quot;z&quot; grammi. Scrivete un programma che determini quante diverse varianti di regali che pesano esattamente `w` grammi può fare Babbo Natale. Il regalo si riferisce a una combinazione di caramelle, mandarini e biscotti che pesano esattamente &quot;w&quot; grammi.