#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define LOG(FMT...) fprintf(stderr, FMT) using namespace std; typedef long long ll; typedef unsigned long long ull; // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template istream &operator>>(istream &is, vector &v) { for (T &x : v) is >> x; return is; } template ostream &operator<<(ostream &os, const vector &v) { if (!v.empty()) { os << v.front(); for (int i = 1; i < v.size(); ++i) os << ' ' << v[i]; } return os; } int main() { #ifdef ELEGIA freopen("test.in", "r", stdin); int nol_cl = clock(); #endif ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { int ans = 1000; vector a(3); cin >> a; for (int i = 0; i < 3; ++i) { int x = a[i], y = a[(i + 1) % 3], z = a[(i + 2) % 3]; int v = 1000, w = 1000; for (int j = 0; j <= 1000; ++j) { int cost = j, dam = 0, mnd = 10000; if (v > 0) { cost += (v + x - 1) / x; dam += (v + x - 1) / x * y; mnd = min(mnd, y); } if (w > 0) { cost += (w + x - 1) / x; dam += (w + x - 1) / x * z; mnd = min(mnd, z); } if (dam - mnd < 1000) ans = min(ans, cost); if (v <= 0 || w <= 0) break; v -= z; w -= y; } } cout << ans << '\n'; } #ifdef ELEGIA LOG("Time: %dms\n", int ((clock() -nol_cl) / (double)CLOCKS_PER_SEC * 1000)); #endif return 0; }