2658 - Arithmetic Progression

Discussion around the problems of the COJ.
Forum rules
Remember that posting AC code is not allowed here. If you are going to ask a question or to post a solution, describe your algorithm instead. Posting AC code will be penalized.
Post Reply
User avatar
ymondelo20
Posts: 1968
Joined: 8 years ago
Location: Universidad de las Ciencias Informáticas
Gender: None specified
Contact:

2658 - Arithmetic Progression

Post by ymondelo20 » 5 years ago



"Every problem has a simple, fast and wrong solution" OJ's Main Law. ;)

mungruez
Posts: 10
Joined: 6 years ago
Gender: None specified

Re: 2658 - Arithmetic Progression

Post by mungruez » 5 years ago

I am getting PRESENTATION ERROR and I have no idea why? I would paste the code but that might be penalized because its soo close to AC I can smell it.

I print n which is calculated from the two equations for (3) Sn=n/2(2a+(n-1)d) (2) 3rdterm= a+2d (3) 3rdLastterm= a+(n-3)d

using these equations one can EASILY SOLVE THIS frustrating problem. its is ONLY PURE maths not computer science, the only part is printing the code and i keep getting presentation error. I know my code it correct why do i keep getting presentation error.here is how I print the two lines they ask for:

printf("%d\n",n); ////---->prints n in one line .

printf("%d",a);
a+=d;
for(i=1; i<n; i++){printf(" %d",a); a+=d;}
printf("\n"); ///-------------------------------------> prints all sequence on the 2nd line .

CAN SOMEONE PLEASE TELL ME WHY IN GOD`S LOVING NAME IS THIS PRESENTATION ERROR I SPENT HOURS TRYING TO FIGURE OUT THIS, JUST A BIG WASTE OF MY PRECIOUS TIME, I HATE THESE KINDS OF THINGS ON COJ, AND THEY KEEP DOING THIS OVER AND OVER LIKE IT A NORM ON COJ TO HAVE THESE SORT OF FUSTRATING PROBLEMS

CLEARLY I PRINT WHAT THE PROBLEM ASKS FOR, MY SOLOUION IS CORECT , WHY IN GOD`S NAME IS THIS PRESENTATION ERROR????
Last edited by mungruez on Tue Dec 03, 2013 1:46 am, edited 1 time in total.

facug91
Posts: 12
Joined: 5 years ago
Gender: None specified

Re: 2658 - Arithmetic Progression

Post by facug91 » 5 years ago

I have the same problem. I haven't done it like you, my solution is more brute force hahaha, but anyway, it's OK and I'm getting Presentation Error, don't know why.

mungruez
Posts: 10
Joined: 6 years ago
Gender: None specified

Re: 2658 - Arithmetic Progression

Post by mungruez » 5 years ago

This is the ac PSUEDOcode :

PRINTLINE(n); ////---->prints n in one line .

PRINT(a); ------>//print ist term
PRINT(" "); ------>//print a space
a+=d; ------->//compute next term
FOR i=1 TO n
PRINT(a); ----->//print term
PRINT(" "); ----->//print a space
a+=d; ----->//compute next term
END FOR

PRINTLINE(); ////---->print a blank line .



I have no idea why, this is ac and the code above is presentation error? it worked for me with many other problems, for this one I dont know why?

rvargas
Posts: 37
Joined: 5 years ago
Gender: None specified

Re: 2658 - Arithmetic Progression

Post by rvargas » 5 years ago

Tienes razón, agregando ese espacio se logra un aceptado.

facug91
Posts: 12
Joined: 5 years ago
Gender: None specified

Re: 2658 - Arithmetic Progression

Post by facug91 » 5 years ago

Is true, we have to leave an space at the end of the line. That usually causes a Presentation Error, but here it's the opposite :roll:

User avatar
ymondelo20
Posts: 1968
Joined: 8 years ago
Location: Universidad de las Ciencias Informáticas
Gender: None specified
Contact:

Re: 2658 - Arithmetic Progression

Post by ymondelo20 » 5 years ago

Obvioulsly, the dataset was wrong ... that white-space should not be in output file.
Fixed--- and rejudged. Time limit changed to 5000 MS.

Please, check your submissions.
Best regards, and thanks for using COJ.
"Every problem has a simple, fast and wrong solution" OJ's Main Law. ;)

User avatar
ymondelo20
Posts: 1968
Joined: 8 years ago
Location: Universidad de las Ciencias Informáticas
Gender: None specified
Contact:

Re: 2658 - Arithmetic Progression

Post by ymondelo20 » 4 years ago

Source limit increased.
"Every problem has a simple, fast and wrong solution" OJ's Main Law. ;)

Post Reply

Return to “Problem set”