#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()
#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y) ? ( (x) > (z) ? (x) : (z) ) : ( (y) > (z) ? (y) : (z) ) )
#define MIN3(x, y, z) ( (x) < (y) ? ( (x) < (z) ? (x) : (z) ) : ( (y) < (z) ? (y) : (z) ) )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))
#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)
#define INF 987654321
#define IINF 987654321987654321
int N,M,T,K,H;
#define MOD 1000000007
ll p[100500]; ll ans = 0;
ll fpow(ll x, ll a){
ll res = 1; ll t = x;
while( a > 0 ){
if( a&1 ) res = ( res * t ) % MOD;
t = (t * t) % MOD;
a >>= 1;
}
return res;
}
ll solve(ll x){
ll cur = 0;
ll res = 1; ll cnt = 0;
bool start = false;
for(int i=1;i<=N;i++){
cur += p[i];
if(cur == x){
//printf("%d %lld\n",i,cnt);
res *= (cnt+1); res %= MOD;
cnt = 0; start = true;
cur = 0;
}
else if(cur == 0 && start ){
cur = 0;
cnt++;
}
}
if( cur != 0 ){
return 0;
}
return res;
}
int main(void){
set<ll> s;
geti(N);
repp(i,N) scanf("%lld",p+i);
ll sum = 0;
for(int i=1;i<=N;i++){
sum += p[i]; s.insert(sum);
}
for(auto e : s ){
if( e != 0 ){
ans += solve(e);
ans %= MOD;
}
}
ll res = 1; ll cnt = 0;
ll cur = 0;
for(int i=1;i<=N;i++){
cur += p[i];
if( cur == 0 ){
cnt++; cur = 0;
}
}
if( cur == 0){
ans += fpow(2,cnt-1);
ans %= MOD;
}
cout << ans-1;
}
Compilation message
UV.cpp: In function 'int main()':
UV.cpp:100:5: warning: unused variable 'res' [-Wunused-variable]
ll res = 1; ll cnt = 0;
^
UV.cpp:87:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
geti(N);
^
UV.cpp:88:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
repp(i,N) scanf("%lld",p+i);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2808 KB |
Output is correct |
2 |
Correct |
0 ms |
2808 KB |
Output is correct |
3 |
Correct |
0 ms |
2808 KB |
Output is correct |
4 |
Correct |
96 ms |
3336 KB |
Output is correct |
5 |
Correct |
89 ms |
3336 KB |
Output is correct |
6 |
Correct |
0 ms |
2808 KB |
Output is correct |
7 |
Incorrect |
26 ms |
2940 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
2940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |