第四题 #include <iostream> (30316)#include<string> using namespace std; int main() { string a; cin>>a; long long ans = 0; int t = 0; for(int i=0;i<a.size();i++) { if(a[i] == '0') { if(t<0) t = 0; t++; if(t>0) ans+=t; } else if(a[i] == '1') { t--; if(t>0) ans+=t; } } cout<<ans<<endl; }
点赞 3

相关推荐

2025-11-11 16:40
已编辑
门头沟学院 人工智能
不知道怎么取名字_:这个有点不合理了,相当于已经毕业了,但还是没转正,这不就是白嫖
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务