为啥本地跑飞快,交上去就T捏

P1001 A+B Problem

DGL__DGL_AFO @ 2024-04-20 16:26:12

#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;
int a,b;
int res;
int ans;
int main()
{
    cin>>a>>b;
    //a=1;b=2;
    srand(time(0));
    while(res<=100000000)
    {
        res++;
        ans=rand();
        if(ans-a==b)
        {
            cout<<ans;
            return 0;
        }
    }

    return 0;
}

a=1,b=2;

本地:

3
--------------------------------
Process exited after 0.1829 seconds with return value 0
请按任意键继续. . .

洛谷


by lgvc @ 2024-04-20 16:28:05

有负数,随机范围也不够


by User774258 @ 2024-04-20 16:29:21

tql


by GoodLuckCat @ 2024-04-20 16:30:04

有没有一种可能 rand() 的值是用 short 来存的


by liangbowen @ 2024-04-20 16:30:17

可以去 IDE 测试一下 rand() 的上下界捏。


by hm2ns @ 2024-04-20 16:32:55

哥你认真的?


by hexuchen @ 2024-04-20 16:33:27

@DGL__DGL 两只 AC https://www.luogu.com.cn/record/156498018


by DGL__DGL_AFO @ 2024-04-20 16:35:03

但本地过a=1,b=2很快,洛谷上就T了


by DGL__DGL_AFO @ 2024-04-20 16:35:19

第一个点


by DGL__DGL_AFO @ 2024-04-20 16:35:35

@hexuchen

看不了Qwq


by hexuchen @ 2024-04-20 16:47:02

@DGL__DGL 再试试


| 下一页