做这道题需要用到的:The On-Line Encyclopedia of Integer Sequences, OEIS。
首先 分暴力是极易的。
cin >> a;
bool flg = false;
for (int b = 1; b <= 100 && !flg; ++ b )
for (int c = 1; c <= 100 && !flg; ++ c )
for (int d = 1; d <= 100 && !flg; ++ d ) {
if (a + b + c + d == __gcd(a, b) + c * d / __gcd(c, d)) {
flg = true;
cout << /*a << ' ' <<*/ b << ' ' << c << ' ' << d << '\n';
break;
}
}你打一下表,输出所有 的答案。(为了美观放云剪贴板里了,你可以分屏看。)
然后就是 OEIS 了。我们约定 x & -x。
第二列 。这显然。
第三列 是 A171977。OEIS 告诉我们:
where is the highest power of dividing .
即 ,其中 且 最大。
你发现 实际上就是 。所以 。
第四列 是 A349102。OEIS 告诉我们:
Increase the odd part of to the next greater odd number to get .
即设 ,其中 是奇数(或者说 最大)。将 增加到较大的下一个奇数 。那么 。
显然 ,即 。其中 还是 。即 。
所以:
单词询问 。
#include <bits/stdc++.h>
using namespace std;
signed main() {
int T;
cin >> T;
while (T -- ) {
int a;
cin >> a;
cout << 1 << ' ' << (a & -a) * 2 << ' ' << (a & -a) * (a / (a & -a) + 2) << '\n';
}
return 0;
}