求助

灌水区

Deuteron @ 2021-07-28 10:29:53

为什么这段代码

#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
ll n, m, fact[N] = {1}, infact[N] = {1}, x, y;
void exgcd(ll a, ll b, ll x, ll y){
    if(!b) {
        x = 1, y = 0;
        return ;
    }
    exgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return ;
}
ll C(int n, int m, int p) {
    if (n < m) return 0;
    return (ll)fact[n] * infact[m] % p * infact[n - m] % p;
}
ll lucas(int n, int m, int p) {
    if (n < p) return C(n, m, p);
    return (ll ) C(n % p, m % p, p) * lucas(n / p, m / p, p) % p;
}
int main() {
    int q;
    cin >>q;
    for (int i=1; i<= q; i++) {
        int n, m, p;
        scanf("%d%d%d", &n, &m, &p);
        for (int i=1; i<p; i++) {
            fact[i] = fact[i - 1] * i % p;
            exgcd(i, p, x, y);
            x = (x % p + p - 1) % p + 1;
            infact[i] = infact[i - 1] * x % p;
        }
        printf("%lld\n", lucas(n + m, m, p));
    }
    return 0;
}

玄学无法编译?


by lym12321 @ 2021-07-28 10:31:22

为什么我能编译它呢(挠头


by Deuteron @ 2021-07-28 10:31:54

在luogu上


by Deuteron @ 2021-07-28 10:36:30

记录


by Chanter @ 2021-07-28 10:38:27

@小可爱萌萌哒 不知道


by Chanter @ 2021-07-28 10:38:44

@小可爱萌萌哒 按说我这本地也能编译


by 0x3F @ 2021-07-28 10:39:11

没有显示编译错误只有编译失败?

大概率是日爆

@小可爱萌萌哒


by 0x3F @ 2021-07-28 10:39:29

再交一次


by 0x3F @ 2021-07-28 10:39:47

@小可爱萌萌哒 @小可爱萌萌哒 @小可爱萌萌哒


by Deuteron @ 2021-07-28 10:40:47

三天了都交不上去


by lym12321 @ 2021-07-28 10:42:00

@0x3F 但其他题没事(


| 下一页