QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#514821#9170. Cycle Gameucup-team1231#Compile Error//C++143.0kb2024-08-11 11:38:332024-08-11 11:38:34

Judging History

你现在查看的是最新测评结果

  • [2024-08-11 11:38:34]
  • 评测
  • [2024-08-11 11:38:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
#define pb push_back
typedef long long ll;

int qp(int x, int t) {
    int ret = 1;
    while(t > 0) {
        if(t & 1) ret = 1LL * ret * x % MOD;
        x = 1LL * x * x % MOD;
        t >>= 1;
    }
    return ret;
}
int mat[2005][2005];
int det(int n) {
    int ret = 1;
    for(int i = 0; i < n; i++) {
        if(mat[i][i] == 0) {
            for(int j = i + 1; j < n; j++) if(mat[j][i] != 0) {
                for(int k = i; k < n; k++) swap(mat[j][k], mat[i][k]);
                ret = MOD - ret;
                break;
            }
            if(mat[i][i] == 0) return 0;
        }
        ret = 1LL * ret * mat[i][i] % MOD;
        int inv = qp(mat[i][i], MOD - 2);
        for(int j = i + 1; j < n; j++) {
            int coef = 1LL * inv * (MOD - mat[j][i]) % MOD;
            for(int k = i; k < n; k++) mat[j][k] = (mat[j][k] + 1LL * mat[i][k] * coef) % MOD;
        }
    }
    return ret;
}

int n, m, a[2005], d[2005], b[2005], ans;

void brute() {
    for(int i = 0; i < m; i++)
        for(int j = 0; j < m; j++)
            mat[i][j] = d[abs(i - j)];
    ans = det(m);
}

int l, tmp[2005];
void sqrx(int arr[]) {
    for(int i = 0; i < 2 * l; i++) tmp[i] = 0;
    for(int i = 0; i < l; i++) for(int j = 0; j < l; j++) tmp[i + j] = (tmp[i + j] + 1LL * arr[i] * arr[j]) % MOD;
    for(int i = 2 * l - 1; i >= l; i--) for(int j = 1; j <= l; j++)
        tmp[i - j] = (tmp[i - j] + 1LL * (MOD - tmp[i]) * b[j]) % MOD;
    for(int i = 0; i < l; i++) arr[i] = tmp[i];
}
void mulx(int arr[]) {
    for(int i = l; i >= 1; i--) tmp[i] = arr[i - 1];
    tmp[0] = 0;
    for(int i = l; i >= l; i--) for(int j = 1; j <= l; j++)
        tmp[i - j] = (tmp[i - j] + 1LL * (MOD - tmp[i]) * b[j]) % MOD;
    for(int i = 0; i < l; i++) arr[i] = tmp[i];
}

int pwm[1005], cur[2005];

int fac() {
    return 1;
}

int main() {
    scanf("%d", &n);
    for(int i = 0; i <= n; i++) scanf("%d", &a[i]);
    for(int i = 0; i <= n; i++) for(int j = 0; i + j <= n; j++)
        d[i] = (d[i] + 1LL * a[j] * a[i + j]) % MOD;

    for(int i = 0; i <= 2 * n; i++) b[i] = d[abs(i - n)];
    
    int ccf = qp(d[n], MOD - 2);
    for(int i = 0; i <= 2 * n; i++) b[i] = 1LL * ccf * b[i] % MOD;
    
    if(m <= 2 * n) brute();
    else {
        l = 2 * n;
        pwm[0] = 1;
        for(int i = 29; i >= 0; i--) {
            sqrx();
            if(m >> i & 1) mulx();
        }
        for(int i = 0; i < n; i++)
            for(int j = 0; j < 2 * n; j++)
                mat[i][j] = d[abs(i - j)];
        
        for(int i = 0; i < n; i++) {
            mulx(cur);
            for(int j = 0; j < l; j++) cur[j] = (cur[j] + 1LL * (MOD - b[i]) * pwm[j]) % MOD;
            for(int j = 0; j < l; j++) mat[i + n][j] = cur[j];
        }
        ans = 1LL * det(2 * n) * qp(b[0], m - 2 * n) % MOD;
        if(n & m & 1) ans = (MOD - ans) % MOD;
    }

    ans = 1LL * ans * fac() % MOD;
    printf("%d\n", ans);
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:85:17: error: too few arguments to function ‘void sqrx(int*)’
   85 |             sqrx();
      |             ~~~~^~
answer.code:48:6: note: declared here
   48 | void sqrx(int arr[]) {
      |      ^~~~
answer.code:86:32: error: too few arguments to function ‘void mulx(int*)’
   86 |             if(m >> i & 1) mulx();
      |                            ~~~~^~
answer.code:55:6: note: declared here
   55 | void mulx(int arr[]) {
      |      ^~~~
answer.code:70:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   70 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
answer.code:71:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   71 |     for(int i = 0; i <= n; i++) scanf("%d", &a[i]);
      |                                 ~~~~~^~~~~~~~~~~~~