Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := mint(getNextInt64(scanner))
	b := mint(getNextInt64(scanner))
	x := mint(getNextInt64(scanner))
	var ans mint
	for x-(a-1) >= 0 {
		c := (x - (a - 1)) / (a - b)
		if c == 0 {
			break
		}
		ans.addAs(a.mod().mul(c.mod()))
		x -= c * (a - b)
	}
	if x >= a {
		ans.addAs(x - a).addAs(a.mod()).addAs(b.mod())
	} else {
		ans.addAs(x.mod())
	}
	fmt.Fprintln(writer, ans)
}

type mint int64

func (mt mint) mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	return mt.pow(mint(0).sub(2))
}
func (mt mint) pow(n mint) mint {
	p := mint(1)
	for n > 0 {
		if n&1 == 1 {
			p.mulAs(mt)
		}
		mt.mulAs(mt)
		n >>= 1
	}
	return p
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}

Python: A, B, X = map(int, raw_input().split())

def check(n):
    if n == 0:
        return True
    v = X - n * A + n * B
    return v - B >= 0

hi = 10**16
lo = 0

while hi - lo > 1:
    mid = (hi + lo) / 2
    if check(mid):
        lo = mid
    else:
        hi = mid

print (X + lo * B) % (10 ** 9 + 7)

Python: #!/usr/bin/env python3
a, b, x = map(int, input().split())
print((x + max(x - b, 0) // (a - b) * b) % 1000000007)

Python: def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7

a, b, x = inpl()
if x < a:
    print(x%MOD)
else:
    e = (x-b)//(a-b)
    print((x + e*b)%MOD)

Python: 

a,b,x = [int(i) for i in input().split()]

d = a - b
n = max(0,(x - b)) // d
ans = x + n * b
print(ans % 1000000007)

Python: #! /usr/bin/env python3

a, b, x = map(int, input().split())
MOD = int(1e9+7)

if x < a:
    res = x % MOD
else:
    k = (x-b) // (a-b)
    res = (x + b*k)
    res %= MOD
print(res)

Python: a, b, x = [int(k) for k in input().split()]

if x >= a:
    d = ((x-b) // (a-b))* b + x
else:
    d = x

print(d%1000000007)

Python: a, b, x = map(int, input().split())
print((x+max(0, x-b)//(a-b)*b)%1000000007)

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll a,b,x;
  cin>>a>>b>>x;

  if(x<a){
    cout<<x%MOD<<endl;
    return 0;
  }
  
  ll ans=(x-a)/(a-b)+1;
  ans%=MOD;
  b%=MOD;
  x%=MOD;
  ans=ans*b%MOD+x;
  ans=(ans+MOD)%MOD;
  cout<<ans<<endl;

  return 0;
}

C++: //↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0 }, dy[] = { 0,1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c;
	d = max((long long)0, (c - b) / (a - b));
	a %= MOD; b %= MOD; c %= MOD; d %= MOD;
	cout << (d*b + c) % MOD << endl;
}

C++: #include <iostream>
using namespace std;

const long long MOD = 1000000007;
int main() {
    long long a, b, x;
    cin >> a >> b >> x;

    long long N = max(0LL, (x - b) / (a - b));
    x %= MOD;
    N %= MOD;
    b %= MOD;
    cout << (x + N * b) % MOD << endl;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;
const int INF=1e9;

signed main(){
  int a,b,x;
  cin>>a>>b>>x;
  if(x<a){
    cout<<x%mod<<endl;
    return 0;
  }
  int n=(x-a)/(a-b)+1;
  n%=mod;
  a%=mod;
  b%=mod;
  x%=mod;
  int ans=x+(n*b)%mod;
  cout<<ans%mod<<endl;
}

C++: #include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, x;
	cin >> a >> b >> x;
	if(x < a) {
		cout << x % MOD << endl;
		return 0;
	}
	ll ans = a % MOD;
	x -= a;
	ll c = (a - b);
	ans += (((x / c) % MOD) * (a % MOD)) % MOD;
	ans += b + ((x % c) % MOD);
	cout << ans % MOD << endl;
}
/* --------------------------------------- */

C++: #define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353LL
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
int main() {
	mp::cpp_int a, b, x;
	cin >> a >> b >> x;
	if (x < a) {
		cout << x%MAX_MOD << endl;
		return 0;
	}
	mp::cpp_int ans = 0;
	mp::cpp_int nya = (x - a) / (a - b);
	nya++;
	ans = (nya%MAX_MOD) * (a%MAX_MOD);
	ans %= MAX_MOD;
	x -= nya * (a-b);
	cout << (ans%MAX_MOD + x%MAX_MOD)%MAX_MOD << endl;
	return 0;
}