CodeForces 398A Cards greedy and violent
After a night of competition, all kinds of YY chaos finally came over. At the beginning, all YY errors occurred. I thought the range of question a and question B was 10 ^ 5, then, the brute-force enumeration B is divided into several portions, and then another YY is continued. Only one o is used to separate the x, so that the remaining o is concentrated together, that is to say, the number of parts of x is always more than the number of parts of o, that is, to separate x as much as possible, and to concentrate o on one piece as much as possible. In front, x is separated, A single o is separated by two portions of x, and there will be a lot of o together in the future. This will satisfy the requirement, and then an error occurs. Because there are several portions with the remainder, such as B = 6, you want to divide it into four parts. I split it into 1, 1, 3, and so on. If this is not the case, we should divide it into 1, 1, 2, 2, and average the first part of the remainder until we split the position, it is mainly to reduce the existence of B. In fact, the part of a is well controlled. The part of a minus the one before which x is to be separated. Each separator consumes only one o, and the remainder is multiplied by the first number, B is calculated in two parts, one is to obtain the remainder distribution, and the other is to divide the obtained value.
ll aa,bb;ll ans ;string ret;void init() {}bool input() {while(cin>>aa>>bb) {return false;}return true;}void cal() {ll mark;ans = 0ll;ret = "";if(aa == 0) {ans = -bb * bb;ll q = bb;while(q--)ret += "x";return ;}if(bb == 0) {ans = aa * aa;ll q = aa;while(q--)ret += "o";return ;}ans = -INF;for(ll i=2;i<=aa + 1;i++) {ll now = (aa - i + 2) * (aa - i + 2) + i - 2;ll tmp = bb/i;ll tt = bb - tmp * i;now -= tt * (tmp + 1ll) * (tmp + 1ll) + (i - tt) * tmp * tmp;if(now > ans) {ans = now;mark = i;}}ll tmp = bb/mark;ll tt = bb - tmp * mark;bool flag = false;ll cnt = 0;for(ll i=1;i