Sunday, May 1, 2016

UVA 1727 - Counting Weekend Days

#include<bits/stdc++.h>
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
#define newl cout<<"\n"
#define putcase cout<<"Case "<<++cse<<":"
using namespace std;
int main()
{
  string days[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
 int t;
 cin>>t;
 while (t--) {
  string m,  d;
  int total =31, start=0,cnt=0;
  cin>>m>>d;
  if(m=="FEB")
    total=28;
  else if(m=="SEP" || m=="APR" || m=="JUN"|| m== "NOV")
    total =30;
   for(int i=0; i<7; i++){
    if(days[i]==d) {
     start=i;
     break;
    }
   }
   for(int i=0; i<total; i++){
    if(days[start]=="SAT"|| days[start]=="FRI")
    cnt++;
    if(start==6)
     start=0;
     else
      start++;
   }
   cout<<cnt<<endl;
   cnt=0;
 }
 return 0;
}

No comments:

Post a Comment