https://uva.onlinejudge.org/index.php?o ... oblem=4923 ( Counting Weekend Days )
I have submitted several Times But its getting WA all the time .
Here is my Code ...
Code: Select all
#include<bits/stdc++.h>
#define MOD 1000000007
#define LL long long
using namespace std;
int main()
{
string month, day;
int test;
scanf("%d", &test);
//freopen("inp.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
while(test--)
{
cin>>month>>day;
int md, ptr;
if(month=="JAN" || month=="MAR" || month=="MAY" || month=="JUL" || month=="AUG" || month=="OCT" || month=="DEC")
md = 31;
else if(month=="APR" || month=="JUN" || month=="SEP" || month=="NOV")
md = 30;
else if(month=="FEB") md = 28;
int cnt = 0, temp;
if(day=="SUN") ptr = 1;if(day=="MON") ptr = 2; if(day=="TUE") ptr = 3;
if(day=="WED") ptr = 4;if(day=="THU") ptr = 5; if(day=="FRI") ptr = 6;if(day=="SAT") ptr = 7;
//cout<<md+ptr-1<<endl;
for(int i=ptr; i<=md+ptr-1; i++)
{
temp = i%7;
if(temp==6 || temp==0) cnt++;
}
printf("%d\n", cnt);
}
return 0;
}
@brianfry ... Over to You .