This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
//这个题目看起来太复杂:https://blog.csdn.net/XieNaoban/article/details/52199420
unsigned N, A, B, Sp, Sq, ansA, ansB;
unsigned long long Pofs, K, nowK;
int main() {
while (scanf("%u%u%u", &N, &Sp, &Sq) != -1) {
K = 0xffffffffffffffff;
for (A = 0; A < 32; ++A)
for (B = 0; B < 32; ++B) {
Pofs = (N - 1) * Sp;
nowK = (Pofs + (Pofs << A) >> B) + Sq;
if (nowK >= N * Sq && nowK < K) K = nowK, ansA = A, ansB = B;
}
printf("%llu %u %u\n", K, ansA, ansB);
return 0;