2 months ago when I have started solving ACM ad-hoc problems, I started with The 3n+1 problem. And I have failed to solve as usual. Then next few days I was thinking some complex solutions for that problem but my misfortune. I have failed again and again I have failed.
Then I have focused on other ad-hoc problems. Solved some and learned that, "Sticky with Story!". The story of some ad-hoc problems have written in such way that readers started to think like they are going to solve a dynamic greedy np-hard problem. :D :D :D. One of my academic fellow who already competed regional math olympierd in Indonesia 2 times, he also gave-up ACM for this The 3n+1 problem!!
Here I am giving some clue for them who have tried this problem already and becoming frasted :)
clue 1: look at data type: declare all of your variables long (%ld)
clue 2: input would not always be given in sorted order. check whether first number < second number
clue 3: Show output in given order: If you swap first number and second number at the beginning of your program then be careful when showing output.
clue 4: If you got Time Limit Exit then check - does your program terminates correctly?
To terminate your program write program like this -
while( scanf("%ld %ld", &firstNumber, &secondNumber) != EOF )
{
// ... rest of your code ...
}
clue 5: The program algorithm is given in story. so you do not need to think about new algorithm.
clue 6: after each output there will be a new line. so,
printf("%ld %ld %ld\n", printNumberOne, printNumberTwo, output);
clue 7: debug, debug and debug if you get wrong output.
This problem is a Brute Force problem. so think straight.
Happy coding.
Friday, July 31, 2015
Thursday, July 16, 2015
ACM problem set - 10055 - Hashmat the Brave Warrior
Hello all. Today is my last fasting day of this Arabic fiscal year. I am preparing myself to celebrate EID-day tomorrow. But I am missing my family a lot. Without them nothing could be fulfilled.
Today I was looking into an acm problem 10055 - Hashmat the brave warrior. At first I was disappointed by the problem setter by thinking that, what a easy problem! - Simple subtraction. And wrote code in 2 minutes and got 3 times penalty from online judge.
What the hell!! simple subtraction :(
Then I read the problem again and again and found the tricks hidden in story. :)
You can try once. just find the tricks. you do not need to solve.
Happy coding.
Today I was looking into an acm problem 10055 - Hashmat the brave warrior. At first I was disappointed by the problem setter by thinking that, what a easy problem! - Simple subtraction. And wrote code in 2 minutes and got 3 times penalty from online judge.
What the hell!! simple subtraction :(
Then I read the problem again and again and found the tricks hidden in story. :)
You can try once. just find the tricks. you do not need to solve.
Happy coding.
Subscribe to:
Posts (Atom)