题目大意:有$n$个顾客买苹果,每个买一半的苹果,有时会送半个苹果。最后卖光了,问卖了多少钱
题解:倒退过来,可以把半个苹果当做一份来算,这样不会有小数
卡点:无
C++ Code:
#include <cstdio>
#include <cstring>
int n, p;
long long ans, now;
char ch[50][50];
int main() {
scanf("%d%d", &n, &p); p /= 2;
for (int i = 1; i <= n; i++) {
scanf("%s", ch[i]);
}
for (int i = n; i; i--) {
now <<= 1;
if (strcmp(ch[i], "halfplus") == 0) now++;
ans += now;
}
printf("%I64d\n", ans * p);
return 0;
}