关于编译器
  • 板块灌水区
  • 楼主xiao__
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/10/18 21:56
  • 上次更新2023/11/2 12:57:18
查看原帖
关于编译器
1007419
xiao__楼主2023/10/18 21:56

rt

#include<bits/stdc++.h>//pal
#define int long long
using namespace std;
int n1,n2,y1,y2,t1,t2,cnt=0;
char a,b,c,d,e,f,g,h;
int my[20]{0,31,-1,31,30,31,30,31,31,30,31,30,31};
bool check1(int x){
	if(x%4==0&&x%100!=0) return 1;
	else if(x%400==0) return 1;
	else return 0; 
} 
bool check2(int x){
    int num=0,T=x;
    while(x){
        num=num*10+x%10;
        x/=10;
    }   
    if(num==T) return true;
    else return false;
}
int pj(int x,int y,int z){
	int ans=0;
	ans+=x;
	ans*=100;
	ans+=y;
	ans*=100;
	ans+=z;
	return ans;
}
signed main(){

	cin>>a>>b>>c>>d>>e>>f>>g>>h;
	n1=((a-'0')*1000+(b-'0')*100+(c-'0')*10+(d-'0'));
	y1=((e-'0')*10+(f-'0'));
	t1=((g-'0')*10+(h-'0'));
	cin>>a>>b>>c>>d>>e>>f>>g>>h;
	n2=((a-'0')*1000+(b-'0')*100+(c-'0')*10+(d-'0'));
	y2=((e-'0')*10+(f-'0'));
	t2=((g-'0')*10+(h-'0'));
	//cout<<n1<<" "<<n2<<" "<<y1<<" "<<y2<<" "<<t1<<" "<<t2<<"\n";
	for(int i=n1;i<=n2;){
		for(int j=y1;;){
			if(j==13){
				j=1;
				i++;
			}
			if(j==2) my[2]=check1(i)?29:28;
			for(int k=t1;;k++){
				if(i==n2&&j==y2&&k==t2){
					cout<<cnt;
					return 0;
				}
				if(k>my[j]){
					j++;
					k=1;
					break;
				}
				if(check2(pj(i,j,k))){
					cnt++;
				}
			}
		}
	} 
	return 0;
}

这段代码开心我114514年,********

为什么本地查不出y1的错误,而洛谷CE......

编译加入如下命令 -std=c++14 -O2

2023/10/18 21:56
加载中...