-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
738d0d5
commit c2f79eb
Showing
4 changed files
with
71 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
# 题目描述 | ||
|
||
给定 $n$ 个数,请你求出它们在模 $998244353$ 的意义下的逆元的和。 | ||
|
||
请注意求和不需要取余。 | ||
|
||
# 输入格式 | ||
|
||
第一行,一个整数 $n(1 \leq n \leq 5 \times 10^6)$。 | ||
|
||
第二行,$n$ 个整数,代表给定的数。 | ||
|
||
# 输出格式 | ||
|
||
一行,一个整数,代表答案。 | ||
|
||
# 输入输出样例 | ||
|
||
```input1 | ||
5 | ||
1 2 3 4 5 | ||
``` | ||
|
||
```output1 | ||
2179500173 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
typedef long long ll; | ||
typedef uniform_int_distribution<> rnd; | ||
typedef uniform_int_distribution<ll> rndll; | ||
typedef uniform_real_distribution<> rndf; | ||
mt19937 egn(time(nullptr)); | ||
const int CASES = 1; | ||
// ============================== | ||
|
||
// ============================== | ||
int main(int argc, char const* argv[]) | ||
{ | ||
for(int _t=1;_t<=CASES;_t++) | ||
{ | ||
ofstream fout(to_string(_t)+".in"); | ||
// ============================== | ||
int n = 1e7; | ||
fout<<n<<endl; | ||
for(int i=1;i<=n;i++) fout<<rnd(1,1e9)(egn)<<" \n"[i==n]; | ||
// ============================== | ||
fout.close(); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
using ll = long long; | ||
const int mod = 998244353; | ||
ll qpow(ll a,ll k) | ||
{ | ||
ll res = 1; | ||
for(;k;k>>=1,a=a*a%mod) if(k&1) res = res*a%mod; | ||
return res; | ||
} | ||
int main() | ||
{ | ||
#ifdef LOCAL | ||
freopen("in.txt", "r", stdin); | ||
freopen("out.txt", "w", stdout); | ||
#endif | ||
ios::sync_with_stdio(false); | ||
cin.tie(nullptr); | ||
int n; | ||
cin>>n; | ||
vector<int> a(n); | ||
for(int i=0;i<n;i++) cin>>a[i]; | ||
vector<ll> s(n+1), sv(n+1), res(n); | ||
s[0] = 1; | ||
for(int i=1;i<=n;i++) s[i] = s[i-1]*a[i-1]%mod; | ||
sv[n] = qpow(s[n], mod-2); | ||
for(int i=n;i>=1;i--) sv[i-1] = sv[i]*a[i-1]%mod; | ||
for(int i=0;i<n;i++) res[i] = sv[i+1]*s[i]%mod; | ||
cout<<accumulate(res.begin(), res.end(), 0ll)<<'\n'; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters