标签:span amp problem ios 操作 problems href names class
思路:
惊讶的发现,所有的蓝球的消除都是独立的;
对于在栈中深度为i的蓝球消除需要2^i次操作;
代码:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; long long ans=0; int main() { // freopen("ball.in","r",stdin); // freopen("ball.out","w",stdout); int n;char ch[105]; long long count=1; scanf("%d",&n); scanf("%s",ch); for(int i=0;i<n;i++) { if(ch[i]==‘B‘) ans+=count; count<<=1; } printf("%lld\n",ans); return 0; }
AC日记——Red and Blue Balls codeforces 399b
标签:span amp problem ios 操作 problems href names class
原文地址:http://www.cnblogs.com/IUUUUUUUskyyy/p/6912744.html