ccfcsp 201503-3 节日
只有90分,哪里错了
#include<bits/stdc++.h>
using namespace std;
bool run(int x)
{
if(x%400==0||(x%4==0&&x%100!=0))
{
return true;
}
return false;
}
int arr1[13],arr2[13];
int main() {
long long a,b,c,y1,y2,sum=0,temp;
arr1[1]=arr1[3]=arr1[5]=arr1[7]=arr1[10]=arr1[8]=arr1[12]=31;
arr1[4]=arr1[6]=arr1[9]=arr1[10]=30;
arr1[2]=28;//平年
arr2[1]=arr2[3]=arr2[5]=arr2[7]=arr2[10]=arr2[8]=arr2[12]=31;
arr2[4]=arr2[6]=arr2[9]=arr2[10]=30;
arr2[2]=29;//闰年
cin>>a>>b>>c>>y1>>y2;
for(int i=y1;i<=y2;i++)
{
sum=0;
for(int j=1850;j<i;j++)
{
if(run(j))
{
sum+=366;
}
else
{
sum+=365;
}
}
if(run(i))
{
for(int j=1;j<a;j++)
{
sum+=arr2[j];
}
}
else
{
for(int j=1;j<a;j++)
{
sum+=arr1[j];
}
}
sum+=2;
sum%=7;
if(sum==0)
{
sum=7;
}
temp=1;
if(sum<=c)
{
temp+=c-sum;
}
else
{
temp+=7+c-sum;
}
temp+=(b-1)*7;
if(run(i))
{
if(temp<=arr2[a])
{
cout<<i<<"/"<<setfill('0')<<setw(2)<<a<<"/"<<setfill('0')<<setw(2)<<temp<<endl;
}
else
{
cout<<"none\n";
}
}
else
{
if(temp<=arr1[a])
{
cout<<i<<"/"<<setfill('0')<<setw(2)<<a<<"/"<<setfill('0')<<setw(2)<<temp<<endl;
}
else
{
cout<<"none\n";
}
}
}
return 0;
}