QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#664444#6637. Perfect StringshuaxiamengjinCompile Error//C++14768b2024-10-21 20:42:132024-10-21 20:42:21

Judging History

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

  • [2024-10-21 20:42:21]
  • 评测
  • [2024-10-21 20:42:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int NN=1e9+7;
int n,c;
int p[20000100],ni[20000100];
int cc(int x,int y){
	if(x<0||y<0||x<y)return 0;
    return p[x]*ni[ y]%NN*ni[x-y]%NN;
}
int mi(int x,int y){
    int sum=1;
    for (;y;y>>=1,x=x*x%NN)
    if(y&1)sum=sum*x%NN;
    return sum;
}
void solve(){
    cin>>n>>c;//n*=2;
    p[0]=1;
    for (int i=1;i<=2*n;i++)
    p[i]=p[i-1]*i%NN;
    ni[2*n]=mi(p[2*n],NN-2);
    for (int i=2*n;i;i--)
    ni[i-1]=ni[i]*i%NN;
    int ans=0;
    int pp=1;
    for (int i=0;i<n;i++){
        ans=(ans+cc(n*2,i)*pp[i]%NN*c%NN*(n-i))%NN;
        pp=pp*(c-1)%NN;
    }
    cout<<ans*mi(n,NN-2)%NN<<"\n";
}
signed main(){
    int T;cin>>T;
    while(T--)solve();
}

详细

answer.code: In function ‘void solve()’:
answer.code:28:30: error: invalid types ‘long long int[long long int]’ for array subscript
   28 |         ans=(ans+cc(n*2,i)*pp[i]%NN*c%NN*(n-i))%NN;
      |                              ^