为什么不开 O2 会 CE
  • 板块学术版
  • 楼主_cbw
  • 当前回复8
  • 已保存回复8
  • 发布时间2025/1/9 12:19
  • 上次更新2025/1/9 19:48:00
查看原帖
为什么不开 O2 会 CE
1188782
_cbw楼主2025/1/9 12:19

真的不是标题党

记录 1 C - CE

记录 2 C O2 - AC

然而,如果你把它们随便丢进一个比较器里:

正在比较文件 ce.c 和 AC.C

FC: 找不到差异

求大佬解答原因

附: 源代码:

// P2613
#include <cctype>
#include <cstdio>
#define MOD 19260817
using namespace std;

char str[20005];

inline int qpow(long long x, int n)
{
    long long rv = 1;
    while (n)
    {
        if (n & 1)
            rv = rv * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return rv;
}

int main()
{
    fread(str, 1, 20005, stdin);
    int x = 0, y = 0;
    char *i = str;
    while (isdigit(*i))
    {
        x = (x * 10 + ((*i) ^ 48)) % MOD;
        ++i;
    }
    while (!isdigit(*i))
        ++i;
    while (isdigit(*i))
    {
        y = (y * 10 + ((*i) ^ 48)) % MOD;
        ++i;
    }
    printf("%d", int((long long)x * qpow(y, MOD - 2) % MOD));
    return 0;
}

报错信息(无 O2):

No valid executable file was produced by the compiler
/tmp/compiler_sxl1p364/src: 在函数‘main’中:
/tmp/compiler_sxl1p364/src:37:14: 警告:格式 ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   37 |     printf("%d", (long long)x * qpow(y, MOD - 2) % MOD);
      |             ~^
      |              |
      |              int
      |             %lld
/nix/store/p58l5qmzifl20qmjs3xfpl01f0mqlza2-binutils-2.40/bin/ld: ./ccVHKgZz.o: in function `main':
src:(.text+0x167): undefined reference to `qpow'
collect2: 错误:ld 返回 1
2025/1/9 12:19
加载中...