12019 - Doom's Day Algorithm

All about problems in Volume 120. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
User avatar
shaon_cse_cu08
New poster
Posts: 50
Joined: Tue May 25, 2010 9:10 am
Contact:

12019 - Doom's Day Algorithm

Post by shaon_cse_cu08 » Thu Jun 16, 2011 9:36 am

Code Removed After AC
Last edited by shaon_cse_cu08 on Mon Nov 07, 2011 6:08 pm, edited 1 time in total.
I'll keep holding on...Until the walls come tumbling down...And freedom is all around ..... :x

User avatar
plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

Re: 12019 Doom's Day Algorithm..WA!! Help me

Post by plamplam » Sun Jul 03, 2011 3:42 pm

Try this input:

Code: Select all

1
10 5
The correct output is Wednesday but your program outputs Thursday instead :wink:
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

User avatar
plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

Re: 12019 Doom's Day Algorithm..WA!! Help me

Post by plamplam » Sun Jul 03, 2011 3:47 pm

Okay this is better and more funny.
Try this input:

Code: Select all

2
9 30
10 1
Do you see it? There is a big hole in your program. Its like I slept on Friday night and woke up to see it was Sunday instead of Saturday. May be it was a dream?
Who told you September has 31 days anyway?
Last edited by plamplam on Tue Aug 02, 2011 1:57 pm, edited 1 time in total.
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

naseef_07cuet
Learning poster
Posts: 62
Joined: Sat Nov 21, 2009 10:17 pm
Location: CUET,Chittagong,Bangladesh

12019 - Doom's Day Algorithm

Post by naseef_07cuet » Wed Jul 20, 2011 2:13 pm

I think this is a quite easy problem...but I am getting WA frequently. Please give me some suggestion.....
here is my code

Code: Select all

//removed after accepted
Last edited by naseef_07cuet on Thu Jul 21, 2011 7:31 am, edited 1 time in total.
If you have determination, you can do anything you want....:)

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Re: 12019-WA!!!

Post by sohel » Wed Jul 20, 2011 6:32 pm

have you tested your code with your own inputs?

After testing with 3/4 inputs, I realized that your code doesn't produce any output if the total number of days from Jan 1 is a multiple of 7 ( where c % 7 becomes 0 ).
For example, test your code with 1 14.

And the longer your code gets, the possibility of errors creeping in increases.

Here is a solution to the problem -

Code: Select all

string day[] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
int start[] = {5, 1, 1, 4, 6, 2, 4, 0, 3, 5, 1, 3};
int main() {
	int test, cases = 1, m, d;
	cin >> test;
	while(test--) {
		cin >> m >> d;
		m--;
		d = (d - 1) + start[m]; d %= 7;
		cout << day[d] << endl;
	}
	return 0;
}

naseef_07cuet
Learning poster
Posts: 62
Joined: Sat Nov 21, 2009 10:17 pm
Location: CUET,Chittagong,Bangladesh

Re: 12019-WA!!!

Post by naseef_07cuet » Thu Jul 21, 2011 7:29 am

Got it...thanks sohel bhai.....that was a really foolish mistake....I have thought about your strategy at the first time...but as their is no question of time limit I did that....

Thanks again....
If you have determination, you can do anything you want....:)

bella9091
New poster
Posts: 1
Joined: Wed Dec 26, 2012 12:26 pm

Re: 12019 Doom's Day Algorithm..WA!! Help me

Post by bella9091 » Wed Dec 26, 2012 12:31 pm

sorry it's not working dudes ........ please don't get funny reply seriously ... Thanks
Bella

sampad74
New poster
Posts: 29
Joined: Wed Jun 18, 2014 3:57 pm
Location: Bangladesh

Re: 12019 Doom's Day Algorithm..WA!! Help me

Post by sampad74 » Tue Aug 05, 2014 3:22 pm

Thanks brianfry .got AC.
Last edited by sampad74 on Wed Aug 06, 2014 3:20 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12019 Doom's Day Algorithm..WA!! Help me

Post by brianfry713 » Wed Aug 06, 2014 1:33 am

Wednesday
not
wednesday
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 120 (12000-12099)”