mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 12:18:50 +00:00
parent
364d5dc01c
commit
63b9b9beec
42
NFLSOJ/0/3632/3632.cpp
Normal file
42
NFLSOJ/0/3632/3632.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <numeric>
|
||||
|
||||
// using std::cin;
|
||||
// using std::cout;
|
||||
std::ifstream cin("segment.in");
|
||||
std::ofstream cout("segment.out");
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 5e5 + 5;
|
||||
const int mod = 1e9 + 7;
|
||||
|
||||
int n;
|
||||
long long a[N], s[N], f[N], sum;
|
||||
std::map<long long, long long> map;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
}
|
||||
|
||||
std::partial_sum(a + 1, a + 1 + n, s + 1);
|
||||
|
||||
f[0] = sum = 1;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
f[i] = sum;
|
||||
sum = ((sum + f[i] - map[s[i]]) % mod + mod) % mod;
|
||||
map[s[i]] = f[i];
|
||||
}
|
||||
|
||||
cout << f[n] << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
NFLSOJ/0/3632/samples/segment1.ans
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3632/samples/segment1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3632/samples/segment1.in
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3632/samples/segment1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3632/samples/segment2.ans
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3632/samples/segment2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3632/samples/segment2.in
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3632/samples/segment2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3632/samples/segment3.ans
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3632/samples/segment3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3632/samples/segment3.in
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3632/samples/segment3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3632/samples/segment4.ans
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3632/samples/segment4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3632/samples/segment4.in
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3632/samples/segment4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3632/samples/segment5.ans
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3632/samples/segment5.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3632/samples/segment5.in
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3632/samples/segment5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user