rnf5114 @ 2023-10-03 22:32:05
70分能过hack代码
#include <iostream>
#include <string>
using namespace std;
string s1,s2,q;
int Y1,y2,ans;
int main(){
cin>>s1>>s2;
Y1=(s1[0]-'0')*1000+(s1[1]-'0')*100+(s1[2]-'0')*10+(s1[3]-'0');
y2=(s2[0]-'0')*1000+(s2[1]-'0')*100+(s2[2]-'0')*10+(s2[3]-'0');
for(int i=Y1;i<=y2;i++){
string tmp=to_string(i);
int n1=tmp[3]-'0',n2=tmp[2]-'0',n3=tmp[1]-'0',n4=tmp[0]-'0';
int yue1=(s2[4]-'0')*10+(s2[5]-'0'),ri1=(s2[6]-'0')*10+(s2[7]-'0');
if(n1==0&&n2<=7){
int d2=28;
if(n1+n2==0||n1*10+n2>yue1||(n1*10+n2==yue1&&ri1<n3*10+n4))
continue;
if(i%4==0&&(i%100!=0||i%400==0)){
d2=29;
}
if(n2==2&&n3*10+n4<=d2){
ans++;
}
else if(n1*10+n2<=12&&n2%2&&n3*10+n4<=31){
ans++;
}
else if(n1*10+n2<=12&&n2%2==0&&n3*10+n4<=30){
ans++;
}
}
else{
if(n1+n2==0||n1*10+n2>yue1||(n1*10+n2==yue1&&ri1<n3*10+n4))
continue;
if(n1*10+n2<=12&&(n1*10+n2)%2&&n3*10+n4<=30){
ans++;
}
else if(n1*10+n2<=12&&(n1*10+n2)%2==0&&n3*10+n4<=31){
ans++;
}
}
}
cout<<ans;
}
100分无法过hack代码
#include <iostream>
#include <string>
using namespace std;
string s1,s2,q;
int Y1,y2,ans;
int main(){
cin>>s1>>s2;
Y1=(s1[0]-'0')*1000+(s1[1]-'0')*100+(s1[2]-'0')*10+(s1[3]-'0');
y2=(s2[0]-'0')*1000+(s2[1]-'0')*100+(s2[2]-'0')*10+(s2[3]-'0');
for(int i=Y1;i<=y2;i++){
string tmp=to_string(i);
int n1=tmp[3]-'0',n2=tmp[2]-'0',n3=tmp[1]-'0',n4=tmp[0]-'0';
if(n1==0&&n2<=7){
int d2=28;
if(n1+n2==0)
continue;
if(i%4==0&&(i%100!=0||i%400==0)){
d2=29;
}
if(n2==2&&n3*10+n4<=d2){
ans++;
}
else if(n1*10+n2<=12&&n2%2&&n3*10+n4<=31){
ans++;
}
else if(n1*10+n2<=12&&n2%2==0&&n3*10+n4<=30){
ans++;
}
}
else{
if(n1+n2==0)
continue;
if(n1*10+n2<=12&&(n1*10+n2)%2&&n3*10+n4<=30){
ans++;
}
else if(n1*10+n2<=12&&(n1*10+n2)%2==0&&n3*10+n4<=31){
ans++;
}
}
}
cout<<ans;
}
by rnf5114 @ 2023-10-03 22:43:03
A了,帖子完结