Two Buckets Advanced

Problem #279

Tags: puzzle c-1

Who solved this?

No translations... yet

Here comes the sequel for Two Buckets problem, kindly presented to us by Clive Fraser aka CSFPython! Thanks a lot!

The problem has not changed except that the values of U, V and T are now considerably larger. As a reminder: measure out T gallons from the endless barrel, using two buckets with volume U and V.

The first line of the problem contains a single integer N.
N lines then follow. Each line contains three values U, V and T, separated by spaces.
For each set of three values find the minimum number of operations needed to obtain the target of T gallons.
Give these answers, separated by spaces, as a single string.

Example:
input:

3
41670503 28572146 13254854
9319230342 2919815119 1240306590
962525911350 475338805669 674080710329

answer:
64384792 9851535568 1200284759740
You need to login to get test data and submit solution.