#include <bits/stdc++.h>using namespace std;
int bear(int x, int a, int b){ int emp = x; int res = x; int newb; while (emp >= a) { int r = emp % a; int q = emp / a; res += q * b; emp = r; emp += q * b; } return res;}
int main(){ int tot, a, b; // tot refers to the total number of the bottles which are consum scanf("%d%d%d", &tot, &a, &b); // a refers to the number of the bottles with which you can get some new bottles of bear int l = 1; // b emmm I believe you have get it. int r = 1000000; // this could be alternated accordingly while (l < r - 1) { int mid = (l + r) / 2; if (bear(mid, a, b) > tot) r = mid; else l = mid; } cout<< l <<" "<< bear(l, a, b)<<endl; cout<< r <<" "<< bear(r, a, b)<<endl;}
int bear(int x, int a, int b){ int emp = x; int res = x; int newb; while (emp >= a) { int r = emp % a; int q = emp / a; res += q * b; emp = r; emp += q * b; } return res;}
int main(){ int tot, a, b; // tot refers to the total number of the bottles which are consum scanf("%d%d%d", &tot, &a, &b); // a refers to the number of the bottles with which you can get some new bottles of bear int l = 1; // b emmm I believe you have get it. int r = 1000000; // this could be alternated accordingly while (l < r - 1) { int mid = (l + r) / 2; if (bear(mid, a, b) > tot) r = mid; else l = mid; } cout<< l <<" "<< bear(l, a, b)<<endl; cout<< r <<" "<< bear(r, a, b)<<endl;}