luogu#P6386. [COCI 2007/2008 #4] VAUVAU

[COCI 2007/2008 #4] VAUVAU

Problem Description

In a small village, the postman, the milkman, and the garbage collector face the same problem every morning: there are two guard dogs in front of House 18. What they do not know is that the dogs’ behavior follows a pattern.

At the start of a day, one dog will be aggressive for aa minutes, then calm for bb minutes. The other dog will be aggressive for cc minutes, then calm for dd minutes. Both dogs repeat this behavior endlessly throughout the day.

Given the times when these three people arrive at House 18, determine how many dogs are aggressive at each time.

Input Format

The first line contains four integers a,b,c,da, b, c, d, as described in the statement.

The second line contains three integers: the time pp when the postman arrives, the time mm when the milkman arrives, and the time gg when the garbage collector arrives.

Output Format

Output three lines, each containing one string, in order for the postman, milkman, and garbage collector. The string indicates how many dogs are aggressive when they arrive.

  • If no dog is aggressive, output none.
  • If exactly one dog is aggressive, output one.
  • If both dogs are aggressive, output both.
2 2 3 3
1 3 4

both
one
none
2 3 4 5
4 9 5

one
none
none

Hint

Constraints

For all testdata, it is guaranteed that 1a,b,c,d,p,m,g<1031 \leq a, b, c, d, p, m, g \lt 10^3.

Notes

Translated from COCI2007-2008 CONTEST #4 T1 VAUVAU

Translated by ChatGPT 5