Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
StableAgOH committed Aug 26, 2024
1 parent 738d0d5 commit c2f79eb
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
15 changes: 13 additions & 2 deletions problems/T/T1015/T1015.md
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
```
25 changes: 25 additions & 0 deletions problems/T/T1015/gen.cpp
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;
}
31 changes: 31 additions & 0 deletions problems/T/T1015/std.cpp
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;
}
4 changes: 2 additions & 2 deletions src/creator/luogu_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def __process_samples(samples: list[list[str]]):
s = ""
for i in range(len(samples)):
sample = samples[i]
s += f"```input{i + 1}\n{sample[0]}\n```\n\n"
s += f"```output{i + 1}\n{sample[1]}\n```\n\n"
s += f"```input{i + 1}\n{sample[0].rstrip()}\n```\n\n"
s += f"```output{i + 1}\n{sample[1].rstrip()}\n```\n\n"
return s

@staticmethod
Expand Down

0 comments on commit c2f79eb

Please sign in to comment.