/* -*- coding: utf-8 -*- * * 2681.cc: No.2681 ゲームセンターの両替 - yukicoder */ #include #include using namespace std; /* constant */ const int K = 10; const int xs[K] = { 1, 5, 10, 50, 100, 500, 1000, 2000, 5000, 10000 }; /* typedef */ /* global variables */ int cs[K]; /* subroutines */ /* main */ int main() { int c, y; scanf("%d%d", &c, &y); for (int i = K - 1; i >= 0; i--) cs[i] = y / xs[i], y %= xs[i]; int r = c - cs[4]; if (r <= 0) puts("no exchange"); else { int sum = 0; for (int i = 5; i < K; i++) sum += cs[i] * xs[i]; int maxr = ((sum / 100) / 5) * 5; if (r > maxr) puts("can't exchange"); else printf("%d\n", (r + 4) / 5 * 5 + cs[4]); } return 0; }