题解 P1664 【每日打卡心情好】
Surpersolo · · 题解
#include<bits/stdc++.h>//废话不多说万能头文件直接上
using namespace std;
int n,m,i,s(0),day,t;
//n有n天,m判断是否打卡,s累计未打卡天数,day累计打卡天数,t经验值
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;//输入多少天
for(i=1;i<=n;i++)
{
cin>>m;//今天打卡了吗?
if(m==1)//打了
{
if(s>0)//先处理一下未打卡的天数
{
day=day-(1<<s-1);
}
if(day<0)//如果天数减到0以下了
{
day=0;
}
t++;//打卡加经验值
day++;//天数+1
s=0;//没有未打卡的天数了
if(day>=3)//如果打卡天数超过3天,经验值额外+1
{
t++;
}
if(day>=7)//同上
{
t++;
}
if(day>=30)//同上
{
t++;
}
if(day>=120)//同上
{
t++;
}
if(day>=365)//同上
{
t++;
}
}
else//如果未打卡
{
s++;//未打卡天数+1
}
}
cout<<t<<endl;//输出经验值
return 0;
}