To solve the problem of determining the snowball size after a given number of months, we need to model the growth of the snowball through each month as an exponential growth process. This approach is because, in each month, the number of new people infected or infected and sunny is proportional to the current size of the snowball.

Approach

  1. Understanding the Problem: From the problem statement, it is evident that the snowball expands each month with a multiplicative factor based on the number of susceptible people and the infection probability. This approach is purely iterative and involves updating the snowball size each month using an exponential growth formula.

  2. Recursive Approach: The snowball starts with an initial size. Each month, the size of the snowball is multiplied by a factor which accounts for the infection rate and the number of susceptible people.

  3. Implementation Steps:
    • Read the initial size of the snowball.
    • Determine the multiplicative factor each month based on the given infection probability and the number of susceptible people.
    • Iterate over each month, updating the snowball size using the multiplicative factor.
    • After a given number of months, print the final snowball size.

Solution Code

#include <iostream>

int main() {
    // Initial size of the snowball in thousands to keep it manageable yields initial snowball is 100K
    double initial_susceptible = 100.0;
    int N = 12;  // Number of months
    const double infection_rate_per_month = 0.6;  // Means 60% infection chance
    const double p = 0.6;  // Mobility rate, 60% mobility per month

    // Calculate final snowball size after N months
    double snowball_size = initial_susceptible;

    for (int month = 0; month < N; ++month) {
    }

    for (int month = 0; month < N; ++month) {
    }
    }

Explanation

  • Initial Setup: The initial snowball size is set to 100 (plural in the problem statement).
  • Iterative Growth: Each month, the snowball size is updated by considering the multiplicative factor. This factor includes the infection rate and mobility rate, both converted into decimals for calculation.
  • Result: After iterating over the given number of months, the snowball size is printed. This approach ensures that each month the growth is multiplicative, leading to exponential growth as desired.

This code effectively models the snowball’s growth over time, ensuring that each iteration accurately represents the snowball’s growth based on the given parameters.

Dela.