Tap here to switch tabs
Problem
Submissions

Problem: Number of People Aware of a Secret

Number of People Aware of a Secret asks how many people know it at the end of day n. Each person shares with one new person daily after a delay, then forgets; return the total modulo a large prime.

Statement

On day 11, exactly one person discovers a secret.

Each person who learns the secret will begin sharing it with one new person every day, but only after a waiting period of delay days from when they first discovered it. Additionally, each person completely forgets the secret forget days after discovering it. Once a person has forgotten the secret (on the day of forgetting and all subsequent days), they can no longer share it.

Given an integer n, determine how many people know the secret at the end of day n. Since the result can be very large, return it modulo 109+710^9 + 7.

Note: A person who discovered the secret on day d can share it starting from day d + delay through day d + forget - 1 (inclusive), and they forget it on day d + forget.

Constraints:

  • 2≤2 \leq n ≤1000\leq 1000

  • 1≤1 \leq delay << forget ≤\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of People Aware of a Secret

Number of People Aware of a Secret asks how many people know it at the end of day n. Each person shares with one new person daily after a delay, then forgets; return the total modulo a large prime.

Statement

On day 11, exactly one person discovers a secret.

Each person who learns the secret will begin sharing it with one new person every day, but only after a waiting period of delay days from when they first discovered it. Additionally, each person completely forgets the secret forget days after discovering it. Once a person has forgotten the secret (on the day of forgetting and all subsequent days), they can no longer share it.

Given an integer n, determine how many people know the secret at the end of day n. Since the result can be very large, return it modulo 109+710^9 + 7.

Note: A person who discovered the secret on day d can share it starting from day d + delay through day d + forget - 1 (inclusive), and they forget it on day d + forget.

Constraints:

  • 2≤2 \leq n ≤1000\leq 1000

  • 1≤1 \leq delay << forget ≤\leq n