You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.1 KiB

2 years ago
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, day = 0, unday = 0, point = 0, sum = 0;//point是当前每天要加的活跃值sum是活跃值总和
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a;
if (a == 1)//如果当天打了卡
{
if (unday > 0) {//如果在这天之前有连续没打卡天数
day -= pow(2, unday - 1);//如上
if (day < 0) day = 0;//处理负数情况
}
unday = 0;//连续没打卡天数清零
day++;//连续打卡天数累加
if (day >= 1 && day < 3) point = 1;//如上的活跃值奖励判断
if (day >= 3 && day < 7) point = 2;
if (day >= 7 && day < 30) point = 3;
if (day >= 30 && day < 120) point = 4;
if (day >= 120 && day < 365) point = 5;
if (day >= 365) point = 6;
sum += point;//累计活跃值总和
} else unday++;//如果当天没打卡,连续没打卡天数累加
}
cout << sum;//输出总和
return 0;//结束程序
}