💟 About the author: Hello everyone, I’m

Ceylan_, you can call meCC❣️

📝 Personal homepage: [Ceylan_’s blog]

🏆 Blogger info: Ordinary freshman withextraordinarydreams

column⚡ I hope everyone can support 😘 and make progress together~

❤️ 🌈 If it helps, please[ Follow ➕ Like ➕ Favorite ], if not, I will try harder 💪

**The Blue Bridge Cup has always had a date issue, here we will take a look at such issues**

# 🌺Knowledge point 1. Judging leap years

**🔺Analysis**

If it is a multiple of 4 and not a multiple of 100, it is a leap year

Leap years that are multiples of 400

#include<bits/stdc++.h> using namespace std; int main() { int year; cin>>year; if(year%4==0&&year%100!=0||year%400==0) { cout << "is a leap year" ; } else { cout << "Not a leap year" ; } return 0; }

# 🌺Knowledge point 2. Judge the day of the week

Kim Larson’s calculation formula, if you are interested, you can check the derivation formula

#include<bits/stdc++.h> using namespace std; int main() { int y,m,d; cin>>y>>m>>d; int w; if(m==1||m==2) { m+=12; y--; } w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400+1)%7; printf("%d\n",w); return 0; }

# 🌺Knowledge point 3. Determine whether the date is legal

#include<bits/stdc++.h> using namespace std; int max_days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; bool check(int year,int month,int day) { if(month ==0 || month > 12) return false; if(day == 0) return false; if(month != 2){ if(day > max_days[month]) return false; } else{ int leap = (year % 4 == 0 && year % 100) || (year % 400 == 0); if(day > 28 + leap) return false; } return true; } int main() { int y,m,d; cin>>y>>m>>d; if(check(y,m,d)) cout<<"Yes"; else cout<<"NO"; return 0; }

# 🌺Blue Bridge Zhenti

## 🌷 **Monday**

**❓Problem description**

Throughout the 20th century (between January 1, 1901 and December 31, 2000), how many Mondays were there? (don’t tell me you don’t know what day of the week it is)

**🔺Topic Analysis**

Calculate how many days are included in the time period, and how many weeks are there in total, you will know how many Mondays there are.

**💬 Code demo**

#include<bits/stdc++.h> using namespace std; int is(int year) { if(year%4==0&&year%100!=0||year%400==0) return 1; return 0; } int main() { int day=0; for(int i=1901;i<2001;i++) { if(is(i)) day+=366; else day+=365; } int ans=day/7; cout<<ans; return 0; }

## 🌷 **Days**

**❓Problem description**

January 1, 2000, was the first day of that year.

So, on May 4, 2000, what day was it in that year?

**🔺Topic Analysis**

I don’t know what to say, just figure it out

**💬 Code demo**

#include <bits/stdc++.h> using namespace std; int main() { cout<<125; return 0; }

## 🌷 **Guess the birthday**

**❓Problem description**

This year’s Arbor Day (March 12, 2012), Xiao Ming went to plant trees with his uncle and friends. During the break, Xiao Ming’s classmates asked his uncle how old he was, and his uncle said, “I’ll give you a question, let’s see who can guess it first!”

“Concatenate the year, month, and day of my birth into an 8-digit number (the month and day are less than two digits, and 0 is added), which is exactly divisible by today’s year, month, and day!”

He thought for a while, and then added: “One more reminder, I was born in June.”

Based on this information, please help Xiao Ming calculate the date of birth of his uncle.

The format is 8 digits concatenated with year, month and day. For example, if it was June 12, 1948, write: 19480612.

**🔺Topic Analysis**

Direct violence can be solved

**💬 Code demo**

#include <bits/stdc++.h> using namespace std; int main() { for(int i = 19000101;i<20120312;i++) { int year = i/10000; int month = i/100 % 100; int day = i%100; if(i%2012 == 0 && month==6 && day<30) { if(i%3 == 0) { if(i%12 == 0) { printf("%d\n",i); } } } } return 0; }

## 🌷 **Date issues**

**❓Problem description**

Xiao Ming is sorting out a batch of historical documents. Many dates appear in these historical documents. Xiao Ming knows that these dates are from January 1, 1960 to December 31, 2059. What makes Xiao Ming headache is that the format of these dates is very inconsistent, some use year/month/day, some use month/day/year, and some use day/month/year.

What’s more troublesome is that the first two digits of the year are also omitted, so that there are many possible dates corresponding to a date in the literature.

For example, 02/03/04, it may be March 04, 2002, February 3, 2004, or March 02, 2004.

Given a date in the literature, can you help Xiao Ming determine what possible dates correspond to it?

**🔺Topic Analysis**

Violently enumerate all days and use knowledge point 3 to make judgments.

**💬 Code demo**

#include<bits/stdc++.h> using namespace std; int max_days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; bool check(int year,int month,int day) { if(month ==0 || month > 12) return false; if(day == 0) return false; if(month != 2){ if(day > max_days[month]) return false; } else{ int leap = (year % 4 == 0 && year % 100) || (year % 400 == 0); if(day > 28 + leap) return false; } return true; } int main() { int a,b,c; scanf("%d/%d/%d",&a,&b,&c); for(int data=19600101;data<=20591231;data++) { int year = data / 10000, month = data % 10000 / 100, day = data % 100; if(check(year,month,day)) { if(year % 100 == a && month == b && day== c || month == a && day == b && year % 100== c || day == a && month == b && year % 100== c) printf("%d-%02d-%02d\n",year,month,day); } } return 0; }

## 🌷 Time display

**❓Problem description**

Xiaolan wants to cooperate with friends to develop a time display website.

On the server, the friend has obtained the current time, expressed as an integer, the number of milliseconds elapsed from January 1, 1970 00:00:00 to the current time.

Now, Xiaolan wants to display this time on the client side. Xiaolan does not need to display the year, month, and day, but only needs to display the hour, minute, and second, and the millisecond does not need to be displayed, and can be directly discarded.

Given a time represented by an integer, output the hour, minute, and second corresponding to the time.

enter description

Enter a line containing an integer representing the time.

output description

Output the current time expressed in hours, minutes and seconds, in the format of HH:MM:SS, where HH indicates the time, the value is 0 to 23, MM indicates the minute, and the value is 0 to 59 , SS means seconds, the value is 0 to 59. If the hour, minute and second are less than two digits, a leading 0 is added.

**🔺Topic Analysis**

The input is milliseconds, and it is simple after converting to seconds

**💬 Code demo**

#include<bits/stdc++.h> using namespace std; int main() { int h; cin>>h; int hh,mm,ss; h = h%(24*60*60*1000); hh = h/(60*60*1000)%24; mm = h/(60*1000)%60; ss = h/(1000)%60; printf("%02d:%02d:%02d\n",hh,mm,ss); return 0; }

## 🌷 year number string

**❓Problem description**

Xiao Ming uses the letter A to correspond to the number 1, B to 2, and so on, and Z to 26. For numbers above 27, Xiaoming uses a string of two or more digits to correspond, for example, AA corresponds to 27, AB corresponds to 28, AZ corresponds to 52, and LQ corresponds to 329.

What is the corresponding string for 2019?

**🔺Topic Analysis**

To convert decimal to 26, you can read this article toprepare for the blue bridge, and save the conversion

**💬 Code demo**

#include <bits/stdc++.h> using namespace std; int main() { int n=2019; string s; while(n) { s=char(n%26-1+'A')+s; n/=26; } cout<<s; return 0; }

## 🌷 Running workout

**❓Problem description**

Xiaolan exercises every day.

Under normal circumstances, Xiaolan runs 1 km a day. If a certain day is Monday or the beginning of the month (1st), in order to motivate himself, Xiaolan has to run 2 kilometers. If it is Monday or the beginning of the month at the same time, Xiaolan also runs 2 kilometers.

Little Blue has been running for a long time, from Saturday, January 1, 2000 (inclusive) to Thursday, October 1, 2020 (inclusive). How many kilometers did Xiaolan run in total during this time?

**🔺Topic Analysis**

Simulate day by day, add the corresponding miles if you meet the conditions

**💬 Code demo**

#include <bits/stdc++.h> using namespace std; int main(){ int months[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int year,month,day; int ans=6; int cnt=0; for(year=2000;year<=2020;year++) { if(year%4==0&&year%100!=0||year%400==0) { months[2]=29; } else { months[2]=28; } for(month=1;month<=12;month++) { for(day=1;day<=months[month];day++) { cnt++; if(ans==8) { ans=1; } if(ans==1||day==1) { cnt++; } ans++; if(year==2020&&month==10&&day==1) { printf("%d",cnt); } } } } return 0; }

## 🌷 Palindrome Date

**❓Problem description**

During the 2020 Chinese New Year, a special date caught everyone’s attention: February 2, 2020. Because if this date is written in the format of “yyyymmdd” as an 8-digit number, it is 20200202, which happens to be a palindrome. We call such dates a palindrome date.

Some people say that 20200202 is a special day “once in a thousand years”. Xiao Ming disagrees with this very much, because less than 2 years later will be the next palindrome date: 20211202, which is December 2, 2021.

Some people also said that 20200202 is not just a palindrome date, but a palindrome date of ABABABA type. Xiao Ming also disagrees with this, because in about 100 years, the next palindrome date of the ABABABA type will be encountered: 21211212, which is December 12, 2121. It’s not”once in a thousand years”, but at most”twice in a thousand years”.

Given an 8-digit date, please calculate which day is the next palindrome date and the next palindrome date of type ABABABA after the date.

**🔺Topic Analysis**

For the first palindrome date, we can flip the year and use knowledge point 3 to judge whether the date is reasonable, and add one to the unreasonable year to continue to judge

For the second palindrome date, extract the specific value of AB, construct the date, and use knowledge point 3 to judge whether it is reasonable

**💬 Code demo**

#include<bits/stdc++.h> using namespace std; int max_days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; bool check(int n) { int year=n/10000; int month=n%10000/100; int day=n%100; if(month ==0 || month > 12) return false; if(day == 0) return false; if(month != 2){ if(day > max_days[month]) return false; } else{ int leap = (year % 4 == 0 && year % 100) || (year % 400 == 0); if(day > 28 + leap) return false; } return true; } int main() { int n; cin>>n; int year=n/10000; int date1,date2; for(int i=year;;i++) { date1=i; int k=i; for(int j=0;j<4;j++) { date1=date1* 10 +k% 10 ; k=k/10; } if(date1>n&&check(date1)) { cout<<date1<<endl; break; } } int ab=n/1000000; for(int i=ab;;++i) { int a=i/10; int b=i%10; int x=b*10+a; date2 = i*1000000+ i*10000 +x*100 +x; if(date2>n&&check(date2)) { cout<<date2<<endl; break; } } return 0; }

I am not talented, if there are any mistakes, welcome to correct me in the comment area. If it is helpful, please [ Follow ➕ Like ➕ Favorite ], if not, I will try harder💪💪💪