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
}

C++: /*  -*- coding: utf-8 -*-
 *
 * 3052.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const long long MOD = 1000000007LL;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll a, b, x;
  scanf("%lld%lld%lld", &a, &b, &x);

  ll sum = x % MOD;
  if (x >= a) {
    ll k = (x - a) / (a - b) + 1;
    sum = (sum + (k % MOD) * (b % MOD)) % MOD;
  }

  printf("%lld\n", sum);
  return 0;
}

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

//WA
typedef unsigned long long int ll;

int main()
{
    ll a, b, c, sum = 0;
    const ll con = 1000000007;

    cin >> a >> b >> c;

    if( a > c )
    {
        cout << c % con << endl;
        return 0;
    }

    sum += c % con;
    if( ( c - a + 1 ) % ( a - b ) == 0 )
        sum += ( ( c - a + 1 ) / ( a - b ) % con ) * ( b % con );
    else
        sum += ( ( ( c - a + 1 ) / ( a - b ) + 1 ) % con ) * ( b % con );

    cout << sum % con << endl;

    return 0;
}

C++: #include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long

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

C++: #include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

const int MAXN = 1000000;
Int fact[MAXN], inv[MAXN];

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

void init_fact() {
    fact[0] = 1;
    for(int i=1; i<MAXN; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    inv[MAXN - 1] = mod_pow(fact[MAXN - 1], MOD-2);
    for(int i=MAXN - 2; i>=0; i--) {
        inv[i] = (inv[i+1] * (i+1)) % MOD;
    }
}

Int comb(int n, int r) {
    if(r < 0 || n < r) return 0;
    return fact[n] * inv[n-r] % MOD * inv[r] % MOD;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}


int main(){
    cin.tie(0);
    Int a, b, x; cin >> a >> b >> x;
    Int ans = (x%MOD);
    if (a <= x){
        ans += ((((x-a)/(a-b)+1)%MOD) * (b%MOD))%MOD;
        ans %= MOD;
    }
    cout << ans << endl;

}

C++: #include <bits/stdc++.h>
#define N 1000000007
using namespace std;

long long a, b, x, c, ans = 0;

int main() {
  cin >> a >> b >> x;
  // (x-a) + (a-b)
  if(x < a)
    ans = x;
  else {
    c = max(0LL, (x - a) / (a - b) + 1);
    ans += (c % N) * (b % N) % N + x % N;
    ans %= N;
  }
  cout << ans % N << endl;
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

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