Files
python/RuMenJingDian/UVa/UVa1591.cpp

22 lines
654 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#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;
}