QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393489#6736. Alice and BobwakakakaWA 1ms3612kbC++171.0kb2024-04-18 17:15:362024-04-18 17:15:36

Judging History

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

  • [2024-04-18 17:15:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3612kb
  • [2024-04-18 17:15:36]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define PSI pair<string,int>
#define  double long double
const int mod=998244353;
using namespace std;
int ksm(int a,int b){
    int ans=1;
    while(b){
        if(b&1) {
            ans*=a;
            ans%=mod;
        }
        a*=a;
        a%=mod;
        b>>=1;
    }
    return ans;
}
void solve() {
    int n;
    cin>>n;
    vector<int>fac(n+1);
    int ans=0;
    fac[0]=1;
    for (int i = 1; i <=n ; ++i) {
        fac[i]=(fac[i-1]*i)%mod;
    }
    if(n==1) {
        cout << 1 << endl;
        return ;
    }
    for (int i = 1; i <n ; ++i) {
        int res=fac[n-i]%mod;
        res%=mod;
        res*=ksm(fac[(n-2*i)+1],mod-2)%mod;
        res%=mod;
        res*=fac[n-i];
        res%=mod;
        ans+=res;
        ans%=mod;
    }
    cout<<ans<<endl;

}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);
    int T = 1;
    //cin >> T ;
    while(T--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3612kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

10

output:

793418701

result:

wrong answer 1st numbers differ - expected: '997920', found: '793418701'