finding out the day of the given WEEK
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%I64d",&a)
#define sff(a,b) scanf("%I64d %I64d",&a,&b)
#define sfff(a,b,c) scanf("%I64d %I64d %I64d",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%I64d %I64d %I64d %I64d",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e) scanf("%I64d %I64d %I64d %I64d %I64d",&a,&b,&c,&d,&e)
#define flop(m,n,q) for(ll i=m;i<n;i+=q)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define ll long long int
#define MAX 1000009
#define Max 1000000009
#define pb push_back
int day_of_week(int d,int m,int y)
{
static int t[]={0,3,2,5,0,3,5,1,4,6,2,4};
y-=m<3;
return (y+y/4-y/100+y/400+t[m-1]+d)%7;
}
string dY(int a)
{
if(a==0)
{
return "Sunday";
}
else if(a==1)
{
return "Monday";
}
else if(a==2)
{
return "Tuesday";
}
else if(a==3)
{
return "Wednesday";
}
else if(a==4)
{
return "Thursday";
}
else if(a==5)
{
return "Friday";
}
else if(a==6)
{
return "Saturday";
}
}
int main()
{
int day,month,year;
while(cin>>day>>month>>year)
cout<<dY(day_of_week(day,month,year))<<endl;
}
using namespace std;
#define sf(a) scanf("%I64d",&a)
#define sff(a,b) scanf("%I64d %I64d",&a,&b)
#define sfff(a,b,c) scanf("%I64d %I64d %I64d",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%I64d %I64d %I64d %I64d",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e) scanf("%I64d %I64d %I64d %I64d %I64d",&a,&b,&c,&d,&e)
#define flop(m,n,q) for(ll i=m;i<n;i+=q)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define ll long long int
#define MAX 1000009
#define Max 1000000009
#define pb push_back
int day_of_week(int d,int m,int y)
{
static int t[]={0,3,2,5,0,3,5,1,4,6,2,4};
y-=m<3;
return (y+y/4-y/100+y/400+t[m-1]+d)%7;
}
string dY(int a)
{
if(a==0)
{
return "Sunday";
}
else if(a==1)
{
return "Monday";
}
else if(a==2)
{
return "Tuesday";
}
else if(a==3)
{
return "Wednesday";
}
else if(a==4)
{
return "Thursday";
}
else if(a==5)
{
return "Friday";
}
else if(a==6)
{
return "Saturday";
}
}
int main()
{
int day,month,year;
while(cin>>day>>month>>year)
cout<<dY(day_of_week(day,month,year))<<endl;
}
মন্তব্যসমূহ
একটি মন্তব্য পোস্ট করুন