Language: C++

#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

void solve() {
    VLL t(2), a(2), b(2);
    REP(i,0,2) cin >> t[i];
    REP(i,0,2) cin >> a[i];
    REP(i,0,2) cin >> b[i];
    if (t[0] * a[0] + t[1] * a[1] == t[0] * b[0] + t[1] * b[1]) {
        cout << "infinity" << endl;
        return;
    }
    if (a[0] > b[0] == a[1] > b[1]) {
        cout << 0 << endl;
        return;
    }
    LL diff = (t[0] * a[0] + t[1] * a[1]) - (t[0] * b[0] + t[1] * b[1]);
    if (diff < 0) {
        diff *= -1;
        swap(a,b);
    }
    // a > b
    if (a[0] < b[0]) {
        /*
        dump("---");
        dump(b[0]);
        dump(a[0]);
        dump(t[0]);
        dump(diff);
        dump((b[0] - a[0]) * t[0]);
        */
        LL x = ((b[0] - a[0]) * t[0] + diff) / diff;
        cout << x * 2 - 1 << endl;
        dump(x * 2 - 1);
    } else {
        //cout << 0 << endl;
        throw exception("hoge");
    }
}

signed main() {
    solve();
    
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:85:31: error: no matching function for call to 'std::exception::exception(const char [5])'
   85 |         throw exception("hoge");
      |                               ^
In file included from /usr/include/c++/14/exception:36,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/exception.h:67:5: note: candidate: 'constexpr std::exception::exception(std::exception&&)'
   67 |     exception(exception&&) = default;
      |     ^~~~~~~~~
/usr/include/c++/14/bits/exception.h:67:15: note:   no known conversion for argument 1 from 'const char [5]' to 'std::exception&&'
   67 |     exception(exception&&) = default;
      |               ^~~~~~~~~~~
/usr/include/c++/14/bits/exception.h:65:5: note: candidate: 'constexpr std::exception::exception(const std::exception&)'
   65 |     exception(const exception&) = default;
      |     ^~~~~~~~~
/usr/include/c++/14/bits/exception.h:65:15: note:   no known conversion for argument 1 from 'const char [5]' to 'const std::exception&'
   65 |     exception(const exception&) = default;
      |               ^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/exception.h:62:5: note: candidate: 'std::exception::exception()'
   62 |     exception() _GLIBCXX_NOTHROW { }
      |     ^~~~~~~~~
/usr/include/c++/14/bits/exception.h:62:5: note:   candidate expects 0 arguments, 1 provided