这可能是全站最长的题解😒
2024-10-23 21:27:54
发布于:广东
8阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
bool rn(int x){
if(x % 4 == 0 and (x % 100 != 0 or x % 400 == 0)){
return 1;
} else {
return 0;
}
}
int _day(int x,int y){
if(y == 1 or y == 3 or y == 5 or y == 7 or y == 8 or y == 10 or y == 12){
return 31;
} else if(y == 2){
if(rn(x)){
return 29;
} else {
return 28;
}
} else {
return 30;
}
}
string pps(int x,string s,int si){
int tmp = x,intsi = 0;
string bans = "";
while(tmp){
bans += char(tmp % 10 + '0');
tmp /= 10;
intsi ++;
}
string cans = "";
for(int i = 0;i < si - intsi;i ++){
cans += '0';
}
bans += cans;
reverse(bans.begin(),bans.end());
return s + bans;
}
string to_string(int x,int y,int z){
string ans = "";
ans = pps(x,ans,4);
ans = pps(y,ans,2);
ans = pps(z,ans,2);
return ans;
}
string _plus(string s){
string tmp = s;
int i = s.size() - 1;
int z = (s[i - 1] - '0') * 10 + s[i] - '0';
i -= 2;
int y = (s[i - 1] - '0') * 10 + s[i] - '0';
i -= 2;
int x = (s[i - 3] - '0') * 1000 + (s[i - 2] - '0') * 100 + (s[i - 1] - '0') * 10 + s[i] - '0';
int day = _day(x,y);
z ++;
if(z > day){
z = 1;
y ++;
}
if(y > 12){
y = 1;
x ++;
}
string ans = to_string(x,y,z);
return ans;
}
int main(){
string a,b;
cin >> a >> b;
if(a == b){
cout << 0;
return 0;
}
int ans = 0;
while(1){
string tmp = a;
reverse(tmp.begin(),tmp.end());
if(tmp == a){
ans ++;
}
a = _plus(a);
if(a == b){
break;
}
}
cout << ans;
return 0;
}
这里空空如也
有帮助,赞一个