<?php
// 1- receive the number of test cases (times the first 'for' loop reads Food in Kg)
fscanf(STDIN, "%d", $NumberOfTestCases);

// 2- the for below will loop X times (X = $NumberOfTestCases) and reads a different $FoodInKg value each time 
for ($i=0;$i<$NumberOfTestCases;$i++) {
    
    // 3- the fscanf below create variable $FoodInKg and atribute the input value to it
    fscanf(STDIN, "%f", $FoodInKg);
    // x-- 2° for -50% comida a cada dia ($i)
    // x-- quando comida <= 1 o 2° for para e imprime dias ($i)

    // 4.0- the for below will simulate Blobs eating half of remaning food
    // 4.1- $FoodInKg/2 until $FoodInKg <= 1kg
    // 4.2- each time the loops happens, the amount of food will be updated
    for($i2=0;$FoodInKg > 1;$i2++);
        $FoodInKg /= 2;
}
    /*  
    x1ª vez entrando
    xi2 0
    xfood 40
    
    xsaídas a partir da primeira:
    xfood 20
    xi2 1
    xfood 10
    xi2 2
    xfood 5
    xi2 3
    xfood 2.5
    xi2 4
    xfood 1.25
    xi2 5
    xentra com food 1.25
    xi2 5
    xsai com food 0.625
    xnão entra mais (0.625 > 1 falso)
    xsai do 2° for e echo "{$i2} dias\n";*/
// 5.0- when the loops above ends the updated days ($i2) will be shown
// 5.1- the first
echo "{$i2} dias\n";
?>

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: