#include #include using namespace std; //#define DISABLE_PRINT #if defined(ENABLE_PRINT) && !defined(DISABLE_PRINT) #define P(...) fprintf(stderr, __VA_ARGS__) #define P2(fmt) fprintf(stderr, fmt) #define LP fprintf(stderr, "L: %d\n", __LINE__) #else #define P(...) ((void)0) #define P2(fmt) ((void)0) #define LP ((void)0) #endif #define rep(i, n) for(int i = 0; i < (int)(n); ++i) #define ALL(x) x.begin(),x.end() using ll = long long; using ull = unsigned long long; int main(int, const char**) { array V; array W{}; rep(i, 4) cin >> V[i]; ll N; cin >> N; auto enc = [&](const array& w) { ll v = 0; rep(i, 4) { v *= 1000; v += w[i]; } return v; }; auto dec = [&](ll e) { array dec; rep(i, 4) { dec[3 - i] = e % 1000; e /= 1000; } return dec; }; using Key = pair; ll c = 0; W[0] = V[0]; map m; Key current; for(c = 0; c < N; ++c) { auto e = enc(W); current = Key{(int)c % 4, e}; if(m.find(current) != m.end()) break; m[current] = c; auto f = c % 4; auto t = (c + 1) % 4; auto move = min(W[f], V[t] - W[t]); W[f] -= move; W[t] += move; } if(c == N) { P("easy\n"); auto ans = W; for(auto a : ans) { cout << a << " "; } cout << endl; return 0; } auto loop = c - m[current]; auto lead = m[current]; auto mod = (N - lead) % loop; P("loop: %lld, lead: %d, mod: %lld\n", loop, lead, mod); for(auto p : m) { { auto d = dec(p.first.second); P("idx: %d, v: %d %d %d %d\n", p.second, d[0], d[1], d[2], d[3]); } if(p.second != mod + lead) continue; auto ans = dec(p.first.second); for(auto a : ans) { cout << a << " "; } cout << endl; break; } return 0; }