2 条题解
-
0
#include<bits/stdc++.h> using namespace std; typedef long long LL; const LL P=12345678910ll; LL s[51100]; int main() { int n;scanf("%d",&n); for(int i=1,t=0,x;i<=n;i++) { scanf("%d",&x); if(!x) t++; else { if(!s[t]) s[t-1]=(s[t-1]+1)%P; else s[t-1]=(s[t-1]+s[t]*2)%P; s[t--]=0; } } printf("%lld",s[0]); return 0; } -
0
#include<bits/stdc++.h> using namespace std; typedef long long LL; const LL P=12345678910ll; LL s[51100]; int main() { int n;scanf("%d",&n); for(int i=1,t=0,x;i<=n;i++) { scanf("%d",&x); if(!x) t++; else { if(!s[t]) s[t-1]=(s[t-1]+1)%P; else s[t-1]=(s[t-1]+s[t]*2)%P; s[t--]=0; } } printf("%lld",s[0]); return 0; }
- 1
信息
- ID
- 2627
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 6
- 标签
- 递交数
- 130
- 已通过
- 37
- 上传者