QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#825313#8977. PyramidjiangzhihuiWA 1045ms3596kbC++14848b2024-12-21 18:13:212024-12-21 18:13:21

Judging History

This is the latest submission verdict.

  • [2024-12-21 18:13:21]
  • Judged
  • Verdict: WA
  • Time: 1045ms
  • Memory: 3596kb
  • [2024-12-21 18:13:21]
  • Submitted

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,4)<<endl;
        // if(i==t)cout<<"\n";
        // else cout<<",";
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3488kb

input:

3
1
2
3

output:

1
5
15

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3556kb

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: 1045ms
memory: 3596kb

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:

-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-291172004
-29...

result:

wrong answer 1st lines differ - expected: '813766151', found: '-291172004'