标签:only pre 五个 sqrt 定义 一个 没有 return eps
我做的第一道交互题。
\(44pts:\)输出\(0\)。
\(100pts:\)
第一个包:解一元二次方程,公式法。
#include<bits/stdc++.h>
using namespace std;
#define Db double
int main()
{
Db a,b,c,var,x1,x2;
cin>>a>>b>>c;
var=b*b-4*a*c;
if(var<0)cout<<"No",exit(0);
x1=(-b+sqrt(var))/2.0/a;
if(!var)cout<<"Only ";
cout<<fixed<<setprecision(6)<<x1;
x2=(-b-sqrt(var))/2.0/a;
if(var)cout<<' '<<x2;
return 0;
}
第二个包:枚举\(+\)快速幂。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Mod1 911
#define Mod2 1248679
#define For(i,x,y)for(i=x;i<=y;i++)
ll ksm(ll x,ll y)
{
if(!y)return 1;
x%=Mod1;
return(y&1?x:1)*ksm(x*x,y>>1)%Mod1;
}
int main()
{
ll x;
For(x,1,20021231)
if(ksm(x,x)+(x^(x%Mod2))==20000000)break;
cout<<x;
return 0;
}
第三个包:考虑化简前面的式子。
\(|2e9-max(|x-1e9|,|x-2e9|,|x-3e9|)|\leq10\)
\(-10\leq2e9-max(|x-1e9,|x-2e9|,|x-3e9|)\leq10\)
\(-10-2e9\leq-max(|x-1e9|,|x-2e9|,|x-3e9|)\leq10-2e9\)
\(2e9+10\geq max(|x-1e9|,|x-2e9|,|x-3e9|)\geq2e9-10\)
\(2e9+10\geq max(|x-1e9|,|x-3e9|)\geq2e9-10\)
\(x>2e9:2e9+10\geq x-1e9\geq2e9-10\)
\(3e9+10\geq x\geq3e9-10\)
\(x\leq2e9:2e9+10\geq3e9-x\geq2e9-10\)
\(-10-2e9\leq x-3e9\leq10-2e9\)
\(1e9-10\leq x\leq1e9+10\)
\(x\leq1234567890\)
\(1e9-10\leq x\leq1e9+10\)
\(21\)个数枚举即可。
#include<bits/stdc++.h>
using namespace std;
#define Db double
#define For(i,x,y)for(i=x;i<=y;i++)
const Db pi=3.141592653589793,eps=1e-8;
int main()
{
int x;
For(x,999999990,1000000010)
if(fabs(sin(pi*(Db(x)+25.0)/32.0))<=eps)break;
cout<<x;
return 0;
}
第四个包:发现\(n\)是两个数的乘积,那么枚举到根号,一通\(lowbit\)操作,跑得蛮快。
\(PS:lowbit\)宏定义一定要加括号,\(qwq\)!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,x,y)for(i=x;i<=y;i++)
#define lowbit(x)(x&-x)
ll n=1463030063184;
bool pd(ll x)
{
return x*(lowbit(x)+lowbit((x-lowbit(x))))==n;
}
int main()
{
ll m,i,x;
m=int(sqrt(n));
For(i,1,m)
{
x=i;
if(pd(x))break;
x=n/i;
if(pd(x))break;
}
cout<<x;
return 0;
}
第五个包:???出题人怀疑我没有电脑???直接放进程序里算啊。。。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll x=1;
cout<<not not not not not not not not x and not (((x + (x ^ 998244353) + (((((x + 123) % 456 * 789) ^ 987) - x * 654) ^ (321 * (x % 2))) - (987654321 ^ ((x * x) >> 1)) - (12344321 * x * x * x) - ((1234321 - x) ^ (123454321 >> 2) / (x - 12321) - ((x + (x * x * x) ^ (x * x)) / (x + 123))) * x + 456789 / (x + 9) + 87654 + (32 << (x + 1))) >> 19) + 1);
return 0;
}
结束了。
标签:only pre 五个 sqrt 定义 一个 没有 return eps
原文地址:https://www.cnblogs.com/May-2nd/p/11690961.html