一边做这道题一边写的题解,感觉有点像个草稿本?
Solution
令 与 接近使 ,将方程化为:
令 ,利用恒等式 构造 。
分类构造
当 为奇数时:
-
当 时:。
-
当 时:。
特殊情况:当 时,;当 时,。
当 为偶数时:
-
当 时:。
-
当 时:。
-
当 , 时:。
特判(打表得来的):
当 时,。
正确性证明
所有构造的基本验证方式相同:
- 。
- 计算得 。
- 代入原方程左右相等。
时间复杂度 。
AC Code
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin>>T;
while(T--){
long long a;
cin>>a;
if(a==1) cout<<"1 2 3\n";
else if(a==3) cout<<"3 2 5\n";
else if(a==1000000000LL) cout<<"1 512 100000512\n";
else if(a&1){
if(a%3!=0) cout<<a-2<<' '<<3<<' '<<a<<'\n';
else cout<<a-4<<' '<<3<<' '<<a-1<<'\n';
}
else{
if(a%3!=1) cout<<a-1<<' '<<6<<' '<<a+2<<'\n';
else{
if(a%4==0) cout<<a-3<<' '<<12<<' '<<a+4<<'\n';
else cout<<1<<' '<<4<<' '<<a+4<<'\n';
}
}
}
return 0;
}