Aggressive Dogs
InterviewTime limit1sMemory limit128 MB
Given two dogs' attack/rest cycle lengths, determine for three given minute timestamps how many dogs are attacking at that minute.
- Level
Easy3 of 10
- Topics
- Math, Simulation, Implementation
- Solved
- No attempts yet
Problem
The mail carrier, milk deliverer, and newspaper deliverer all dislike visiting Sanggeun's house. Two aggressive dogs guard the house.
Each morning, the first dog repeats the same cycle forever: it attacks for A minutes, then rests quietly for B minutes. The second dog repeats its own cycle: it attacks for C minutes, then rests quietly for D minutes.
Given the arrival times of the mail carrier, milk deliverer, and newspaper deliverer, determine how many dogs attack each person.
Input
The first line contains four integers A, B, C, and D.
The second line contains three integers P, M, and N. P is the mail carrier's arrival time, M is the milk deliverer's arrival time, and N is the newspaper deliverer's arrival time.
The morning starts at time 0. An arrival time is the number of the minute that is currently in progress after the morning begins. For example, if P is 3, the mail carrier arrives during the third minute after the morning starts.
All numbers are integers between 1 and 999, inclusive.
Output
Print three lines. The first line is the number of dogs that attack the mail carrier, the second line is the number of dogs that attack the milk deliverer, and the third line is the number of dogs that attack the newspaper deliverer.