You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
525 B

1 year ago
// https://www.luogu.com.cn/problem/solution/B3925
1 year ago
#include <iostream>
1 year ago
using namespace std;
int main() {
1 year ago
long long n, i, j, k;
cin >> n >> i;
for (j = 1;; j++) {
bool flag = true;
long long ans = j * n + i;
for (k = 1; k < n; k++) {
if (ans % (n - 1)) {
flag = false;
break;
}
ans = ans / (n - 1) * n + i;
}
if (flag) {
cout << ans;
return 0;
1 year ago
}
}
}