問題一覧 > 通常問題

No.1486 Robots

レベル : / AI推定難易度 : 600 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 212
作問者 : tarattata1 / テスター : ngtkana
お気に入りにしたユーザー ProblemId : 3362 / 自分の提出
問題文最終更新日: 2021-04-23 20:49:14
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 292 (順位表) の他の問題:

Problem Statement

There are two robots.
When switched on, the first robot repeats the following over and over: "move for $A$ seconds, then stop for $B$ seconds".
When switched on, the second robot repeats the following over and over: "move for $C$ seconds, then stop for $D$ seconds".
Now, the two robots have been switched on at the same time.
Up until $E$ seconds later, for how many seconds (out of the $E$ seconds) are both robots moving at the same time?

Input

$A\ B\ C\ D\ E$

  • All inputs are integers
  • $1\leqq A,B,C,D\leqq 500$
  • $1\leqq E\leqq 10^9$

Output

Print the answer in seconds as an integer, followed by a newline.

Sample

Sample 1
Input
3 2 3 1 10
Output
5

During the period up until 10 seconds after both robots are switched on at the same time,
the first robot moves from 0 seconds to 3 seconds and from 5 seconds to 8 seconds.
The second robot moves from 0 seconds to 3 seconds, from 4 seconds to 7 seconds, and from 8 seconds to 10 seconds.
Both robots move at the same time from 0 seconds to 3 seconds and from 5 seconds to 7 seconds, for a total of 5 seconds.

Sample 2
Input
2 1 3 4 20
Output
6

Sample 3
Input
4 1 8 2 1000000000
Output
700000000

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。