結果
問題 |
No.1486 ロボット
|
ユーザー |
|
提出日時 | 2021-12-27 17:18:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 579 bytes |
コンパイル時間 | 344 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 86,020 KB |
最終ジャッジ日時 | 2024-09-25 11:01:41 |
合計ジャッジ時間 | 1,738 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
import math M1, S1, M2, S2, N = map(int, input().split()) T1 = M1 + S1 T2 = M2 + S2 def my_lcm(x, y): return (x * y) // math.gcd(x, y) LCD = my_lcm(T1, T2) dp = [0] * (LCD * 2) i = 0 while i <= LCD: for j in range(M1): dp[i] += 1 i += 1 for j in range(S1): i += 1 i = 0 while i <= LCD: for j in range(M2): dp[i] += 1 i += 1 for j in range(S2): i += 1 if LCD < N: cnt = dp[:LCD].count(2) mod = N % LCD ans = cnt * (N // LCD) + dp[:mod].count(2) else: ans = dp[:N].count(2) print(ans)