升级版

P1001 A+B Problem

DGL__DGL_AFO @ 2024-04-20 16:52:46

现在随机数能取到int范围力

而且可以用minn和maxx调整区间大小来减少时间复杂度

但只AC了三个点...

#include<bits/stdc++.h>
#include<random>
int minn,maxx;
typedef long long ll;
using namespace std;
ll a,b;
ll res;
ll ans;

int main()
{
    cin>>a>>b;
    minn=min(a,b)-abs(min(a,b));
    maxx=max(a,b)+abs(max(a,b));
    //a=1;b=2;
    random_device seed;
    ranlux48 engine(seed());
    uniform_int_distribution<> distrib(minn, maxx);
    while(1)
    {
        ans=distrib(engine);
   // cout<<ans<<endl;
        if(ans-a==b)
        {
            cout<<ans;
            return 0;
        }

    }

    return 0;
}

by GoodLuckCat @ 2024-04-20 17:14:50

GPT 帮我改了一下,变好了,因为每次都能50分了()


by DGL__DGL_AFO @ 2024-04-20 17:18:55

@GoodLuckCat

神奇.c++20比c++14多对两个点


by Cute_QiQi @ 2024-04-26 20:01:05

@DGL__DGL 这题好像...


#include<bits/stdc++.h>

using namespace std;

int main(){

int a.b;cin>>a>>b;cout<<a+b;

}

上一页 |