枚举好题,直接枚举答案 看看在不在范围内就行了 注意二月份
92200229是合法的~
82200228也是合法的!
#include<bits/stdc++.h>
using namespace std;map<int,int>mp;int main()
{mp[1] = mp[3] = mp[5] = mp[7] = mp[8] = mp[10] = mp[12] = 31;mp[2] = 29;mp[4] = mp[6] = mp[9] = mp[11] = 30;int n,m;cin>>n>>m;int res = 0;for(auto [x,y]:mp){for(int j=1;j<=y;j++){string tem = to_string(x*100+j);if(tem.size()<4)tem = '0'+tem;string tem1 = tem;reverse(tem.begin(),tem.end());tem+=tem1;// if(tem[0]=='0')continue;int st = stoi(tem);if(st>=n&&st<=m)res++; }}cout<<res;
}