cpp
#include "bits/stdc++.h"
#define int long long
using namespace std;
char c[10000000];
char s[10000000];
int cnt,Ans,mr,mid;
int maxi;
int p[10000000],pre[10000000];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
scanf("%s",c+1);
int n=strlen(c+1);
s[++cnt]='~';
s[++cnt]='#';
for(int i=1;i<=n;i++)
s[++cnt]=c[i],s[++cnt]='#';
s[++cnt]='!';
for(int i=1;i<=cnt;i++)
{
pre[i]=pre[i-1];
if(s[i]=='1')
pre[i]++;
if(i<=mr) p[i]=min(p[mid*2-i],mr-i+1);
else p[i]=1;
while(s[i+p[i]]==s[i-p[i]]) p[i]++;
if(i+p[i]>mr) mr=i+p[i]-1,mid=i;
if(s[i]!='1'&&pre[i]-pre[i-p[i]]>pre[maxi]-pre[maxi-p[maxi]])
maxi=i;
}
int k=pre[cnt]-(pre[maxi]-pre[maxi-p[maxi]]);
cout<<k;
}
cpp
#include <bits/stdc++.h>
#define int long long
using namespace std;
int cnt[12]={13,1,2,3,5,4,4,2,2,2};
int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int check(int year)
{
if((year%4==0&&year%100!=0)||year%400==0)
return 1;
else
return 0;
}
int getd(int year,int month)
{
if(check(year)&&month==2)
return days[month]+1;
return days[month];
}
int getb(int date)
{
int sum=0;
while(date)
{
sum+=cnt[date%10];
date/=10;
}
return sum;
}
int cntt=0;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
for(int year=2000;year<=2024;year++)
{
for(int month=1;month<=12;month++)
{
for(int day=1;day<=getd(year,month);day++)
{
int date=year*10000+month*100+day;
if(getb(date)>50&&(date<=20240413))
cntt++;
}
}
}
cout<<cntt;
}