Files
python/LuoGu/RuMen/P1664.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

29 lines
1.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;//结束程序
}