为什么本地和在线的结果不一样?
查看原帖
为什么本地和在线的结果不一样?
235696
muvum楼主2022/7/16 16:09

求助各位大佬,第一个测试点下下来发现输出正确,而且没有超时,但在线就大红大紫,是代码写的有纰漏吗?

评测记录

#include <iostream>
#define re register

const int MOD = 1e9+7;

namespace IO {
    char buf[1<<20], *p1 = buf, *p2 = buf;
    #define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
    inline void read(int &x) {
        x = 0; bool f = 0; char c = gc();
        while (!isdigit(c)) { if (c == '-') f = 1; c = gc();}
        while (isdigit(c)) { x = (x * 10LL + c - '0') % MOD; c = gc();}
        if (f) x = (MOD - x) % MOD;
    }
}
using IO::read;

int n, m, cnt, a[101], ans[1000001];

int main(void) {
    std::ios::sync_with_stdio(false);

    std::cin >> n >> m;
    for (re int i=0; i<=n; ++i) read(a[i]);

    for (re int i=1,sum; i<=m; ++i) {
        sum = a[n]; for (int j=n-1; j>=0; --j)
            sum = ((long long)sum * i + a[j]) % MOD;
        if (sum == 0) ans[++cnt] = i;
    }

    std::cout << cnt << '\n';
    for (int i=1; i<=cnt; ++i) std::cout << ans[i] << '\n';

    return 0;
}
2022/7/16 16:09
加载中...