寒假作业打卡
#include <iostream>
using namespace std;
int x;
int main(void) {
int ans = 0, last_score = -1;
while (scanf("%d", &x), x) {
if (x == 1) {
++ans;
last_score = 1;
} else {
if (last_score == -1 || last_score == 1) {
ans += 2;
last_score = 2;
} else {
ans += last_score + 2;
last_score += 2;
}
}
}
printf("%d\n", ans);
return 0;
}