QOJ.ac
QOJ
QOJ is currently under a maintenance. It might be unavailable in the following a few hours.
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#825442 | #8977. Pyramid | jiangzhihui | WA | 996ms | 3688kb | C++14 | 844b | 2024-12-21 19:25:20 | 2024-12-21 19:25:23 |
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+=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,4)<<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: 3684kb
input:
3 1 2 3
output:
1 5 15
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
10 20 1 15 17 11 2 15 3 16 3
output:
8855 1 3060 4845 1001 5 3060 15 3876 15
result:
ok 10 lines
Test #3:
score: -100
Wrong Answer
time: 996ms
memory: 3688kb
input:
1000000 709877 145493 170549 915888 2504 680394 758139 24665 365499 242644 535590 994789 297247 518365 834337 852392 945750 480961 126953 485671 11673 262033 473744 199902 743475 91856 394619 779195 616388 60537 756645 570144 510464 285494 932570 298148 627373 110058 469501 686867 559208 82153 90754...
output:
112407193 -906107500 538873372 -329264913 145136568 -632938447 16855070 -475465228 670106829 353659111 313652563 42378869 -200441708 -337011226 736683159 -389645534 188900616 -966146657 -662552359 511251072 -888561373 -712216428 -298324893 -63980607 949903674 -357354079 973926616 -320802424 -9005336...
result:
wrong answer 1st lines differ - expected: '813766151', found: '112407193'