x0, y0, ax, ay, bx, by = map(int, input().split())
x, y, t = map(int, input().split())
xaxis = [];yaxis = [];dis = 3*(10 ** 16);
xaxis.append(x0)
yaxis.append(y0)
lim=120;ans=0
for i in range(0, lim):
xaxis.append(xaxis[i] * ax + bx)
yaxis.append(yaxis[i] * ay + by)
for j in range(0,lim):
inx=j
tim = 0
cnt = 0
x1=x
y1=y
for i in range(inx, -1, -1):
tmp = abs(xaxis[i] - x) + abs(yaxis[i] - y)
if tim + tmp > t:
break
x = xaxis[i]
y = yaxis[i]
tim += tmp
cnt += 1
for i in range(inx + 1, lim):
tmp = abs(xaxis[i] - x) + abs(yaxis[i] - y)
if tim + tmp > t:
break
x = xaxis[i]
y = yaxis[i]
tim += tmp
cnt += 1
x=x1
y=y1
ans=max(ans,cnt)
print(ans)
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
long long x0, y0, ax, ay, bx, by, xs, ys, t;
void Input() {
cin >> x0 >> y0 >> ax >> ay >> bx >> by;
cin >> xs >> ys >> t;
}
void Solve() {
vector<long long> x(1, x0), y(1, y0);
long long LIMIT = (1LL << 62) - 1;
while ((LIMIT - bx) / ax >= x.back() && (LIMIT - by) / ay >= y.back()) {
x.push_back(ax * x.back() + bx);
y.push_back(ay * y.back() + by);
}
int n = x.size();
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
long long length = x[j] - x[i] + y[j] - y[i];
long long dist2Left = abs(xs - x[i]) + abs(ys - y[i]);
long long dist2Right = abs(xs - x[j]) + abs(ys - y[j]);
if (length <= t - dist2Left || length <= t - dist2Right)
ans = max(ans, j - i + 1);
}
}
cout << ans << endl;
}
int main(int argc, char *argv[]) {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
Input();
Solve();
return 0;
}
1343C - Alternating Subsequence | 1325A - EhAb AnD gCd |
746A - Compote | 318A - Even Odds |
550B - Preparing Olympiad | 939B - Hamster Farm |
732A - Buy a Shovel | 1220C - Substring Game in the Lesson |
452A - Eevee | 1647B - Madoka and the Elegant Gift |
1408A - Circle Coloring | 766B - Mahmoud and a Triangle |
1618C - Paint the Array | 469A - I Wanna Be the Guy |
1294A - Collecting Coins | 1227A - Math Problem |
349A - Cinema Line | 47A - Triangular numbers |
1516B - AGAGA XOOORRR | 1515A - Phoenix and Gold |
1515B - Phoenix and Puzzle | 155A - I_love_username |
49A - Sleuth | 1541A - Pretty Permutations |
1632C - Strange Test | 673A - Bear and Game |
276A - Lunch Rush | 1205A - Almost Equal |
1020B - Badge | 1353A - Most Unstable Array |