#5. Guess Date

题面

提交记录

我做的第一道交互题。

\(44pts:\)输出\(0\)

\(100pts:\)

第一个包:解一元二次方程,公式法。

#include
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<

第二个包:枚举\(+\)快速幂。

#include
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<

第三个包:考虑化简前面的式子。

\(|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\)

\(\because x\leq1234567890\)

\(\therefore 1e9-10\leq x\leq1e9+10\)

\(21\)个数枚举即可。

#include
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<

提示:它竟然是个常用的模数。

第四个包:发现\(n\)是两个数的乘积,那么枚举到根号,一通\(lowbit\)操作,跑得蛮快。

\(PS:lowbit\)宏定义一定要加括号,\(qwq\)

#include
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<

第五个包:???出题人怀疑我没有电脑???直接放进程序里算啊。。。

#include
using namespace std;
typedef long long ll;
int main()
{
    ll x=1;
    cout<> 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;
}

结束了。

你可能感兴趣的:(#5. Guess Date)