借题求问g++: 编译器内部错误
查看原帖
借题求问g++: 编译器内部错误
687685
not_so_littlekayen楼主2025/7/25 21:10

此份代码给出了如下的错误提示

请提交一份完整的错误报告,
如有可能请附上经预处理后的源文件。
参阅 <https://gcc.gnu.org/bugs/> 以获取指示。
#include <iostream>
#include <cstdio>
using namespace std;
#define int long long
const int mod = 998244353;
int t, n, m, k;
int f[10000010] = {1, 1};
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> t;
    for (int i = 2;i <= 10000000;i++)f[i] = f[i-1]*i%mod;
	while(t--)
	{
		cin >> n >> m >> k;
		if(m == 0)
        {
            cout << f[n]*k%mod << "\n";
            continue;
        }
		int cnt = 0;
		for(int i = 1;i*i <= m;i++)
		{
			if(m%i == 0)
			{
				if(i <= n)cnt++;
				if(i != m/i&&m/i <= n)cnt++;
			}
		}
		int ans = cnt*f[n-1]%mod*k%mod+(n*(n+1)/2-k+mod)%mod*(n-cnt)%mod*f[n-2]%mod;
		cout << ans << "\n";
	}
	return 0;
}

去问了DS改程序改成了AC代码

#include <cstdio>
#define int long long
const int Max = 1e7 + 7, mod = 998244353;
int t, n, m, k;
int f[Max];
void init()
{
    f[0] = f[1] = 1;
    for (int i = 2;i < Max; ++i)
        f[i] = f[i - 1] * i % mod;
}
signed main()
{
    init();
    scanf("%lld", &t);
    while(t--)
    {
        scanf("%lld%lld%lld", &n, &m, &k);
        if(m == 0)
        {
            printf("%lld\n", f[n]*k%mod);
            continue;
        }
        int cnt = 0;
        for (int i = 1;i*i <= m;++i)
        {
            if(m%i == 0)
            {
                if (i <= n) cnt++;
                if (i != m/i&&m/i <= n) cnt++;
            }
        }
        int res1 = cnt*f[n-1]%mod*k%mod, res2 = 0;
        int h = n*(n+1)/2;
        res2 = (h%mod-k+mod)%mod;
        res2 = res2*(n-cnt)%mod*f[n-2]%mod;
        int ans = (res1+res2)%mod;
        printf("%lld\n", ans);
    }
    return 0;
}

所以

1.这个问题是什么?2.为什么出现这个问题?

2025/7/25 21:10
加载中...