#include using namespace std; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define FORR(i, m, n) for (int i = m; i >= n; --i) #define ALL(v) (v).begin(),(v).end() templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> a >> b >> c >> d >> e; int x=(a+b)*(c+d); vector sm(x+1); FOR(i,1,x+1){ if(i%(a+b)!=0&&i%(a+b)<=a&&i%(c+d)!=0&&i%(c+d)<=c) sm[i]=sm[i-1]+1; else sm[i]=sm[i-1]; } cout << e/x*sm[x]+sm[e%x] << endl; }