package main import . "fmt" import . "math/big" func main() { var n,p,q,r,a,b,c int64 Scan(&n,&p,&q,&r,&a,&b,&c) ans := solve(n,p,q,r,a,b,c) Println(ans) } func solve(n,p,q,r,a,b,c int64) (ans int64) { pqr := p*q*r X, Y, Z := new(Int), new(Int), new(Int) new(Int).GCD(nil, X, NewInt(p), NewInt(pqr/p)) new(Int).GCD(nil, Y, NewInt(q), NewInt(pqr/q)) new(Int).GCD(nil, Z, NewInt(r), NewInt(pqr/r)) X.Mul(X, NewInt(pqr/p)).Mul(X, NewInt(a)) Y.Mul(Y, NewInt(pqr/q)).Mul(Y, NewInt(b)) Z.Mul(Z, NewInt(pqr/r)).Mul(Z, NewInt(c)) xyz := new(Int).Add(X, new(Int).Add(Y, Z)) m := new(Int).Mod(xyz, NewInt(pqr)).Int64() ans = n / pqr if n % pqr >= m { ans++ } return }