QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#825316 | #8977. Pyramid | jiangzhihui | WA | 0ms | 3656kb | C++14 | 848b | 2024-12-21 18:14:31 | 2024-12-21 18:14:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int c[100]={0,1,5,15,35,70,126,210,330,495,715};
int ksm(int a,int b){
int ans=1;
while(b){
if(b&1)ans=ans*a%mod;
a=a*a%mod;
b>>=1;
}
return ans%mod;
}
int f(int x,int n){//n阶多项式
int ans=0;
for(int i=1;i<=n+1;i++){//
int fz=c[i];//y(i)
int fm=1;
for(int j=1;j<=n+1;j++){
if(j==i)continue;
fz*=(x-j);
fm*=(i-j);
}
ans+=1.0*fz*ksm(fm,mod-2);
ans%=mod;
}
return ans;
}
signed main(){
int t,x;
cin>>t;
for(int i=1;i<=t;i++){
// x=i;
cin>>x;
cout<<f(x,5)<<endl;
// if(i==t)cout<<"\n";
// else cout<<",";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
3 1 2 3
output:
1 5 15
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3532kb
input:
10 20 1 15 17 11 2 15 3 16 3
output:
8856 1 3060 4848 1001 5 3060 15 3874 15
result:
wrong answer 1st lines differ - expected: '8855', found: '8856'