problem statement is here
#include<stdio.h>
int main()
{
long long int t,i,month,year1,year2,x,y,total_days,u,a,b,c,d,e;
scanf("%lld",&t);
while(t--)
{
int arr[13];
arr[1]=31,arr[2]=28,arr[3]=31,arr[4]=30,arr[5]=31,arr[6]=30,arr[7]=31,arr[8]=31,arr[9]=30,arr[10]=31,arr[11]=30,arr[12]=31;
total_days=0;
scanf("%lld %lld",&year1,&year2);
y=1901;
month=12;i=0;
if(year1>1901){
while(y<year1){
if((y%4==0&&y%100!=0)||y%400==0){
total_days+=366;
}else{
total_days+=365;
}
y=y+1;
}
}
u=0;
i=total_days%7;
total_days=i;
if(i==4){
u++;
}
for(x=year1;x<=year2;x++){
for(y=1;y<=12;y++){
if(x==year2 && y==12)
break;
if(y==2){
if((x%4==0&&x%100!=0)||x%400==0){
total_days+=29;
}else{
total_days+=28;
}
}else
total_days+=arr[y];
if(total_days%7==4){
u++;
}
}
}
total_days=total_days+31-i-u;
a=total_days/144000;
total_days-=(a*144000);
b=total_days/7200;
total_days-=(b*7200);
c=total_days/360;
total_days-=(c*360);
d=total_days/20;
total_days-=(d*20);
e=total_days;
printf("%lld.%lld.%lld.%lld.%lld\n",a,b,c,d,e);
}
return 0;
}
No comments:
Post a Comment