Page 1 of 2

1049 - Sum

Posted: Mon Feb 06, 2012 1:23 pm
by dovier

Re: 1049 - Sum

Posted: Mon May 26, 2014 2:19 am
by alvarofloresmx
I was wondering if there's any chance this problem might be wrong when interpreting C# answers

I used the custom tool of the Datagen and used my code to compare my answers to the one that was suppose to be. I used different numbers and got it right but whenever I try to submit it it gives me a "Wrong answer" error.

I could submit my code but well I shouldn't.

Re: 1049 - Sum

Posted: Wed May 28, 2014 5:24 pm
by ymondelo20
You can post your code, because it´s not accepted.

Problem 1049

Posted: Mon Apr 13, 2015 12:43 pm
by Pedro
I tried this problem a few times, I always get the input and output right, but when I submit the problem in COJ it always judge the answer as wrong.
this is the my code:

using namespace std;
int main()

int n,sum = 0;

cin >> n;

for(int i = 1; i <= n; i++)
sum = sum + i;

cout << sum;
return 0;

I also tried the problem using this formula : (N(N+1))/2
and the same thing happens, The program gives me the right output but COJ still judge it as wrong answer.

Any tips on what I am doing wrong here?

Re: 1049 - Sum

Posted: Mon Apr 13, 2015 5:29 pm
by humbertodiaz
Hello Pedro. Threads have been created for each exercise ahead of time. This makes it so that exercises on COJ can have links to their respective threads on the forums. I've merged your post into the correct thread since there is no need to create a new one.

Regarding your problem, you may want to read the wording of the exercise very carefully. Does your program give the correct output for all possibles values of N?

Re: 1049 - Sum

Posted: Mon Apr 13, 2015 6:17 pm
by ymondelo20
Haaa ... common mistake...
You will punish yourself at the end.

Re: 1049 - Sum

Posted: Tue Apr 21, 2015 10:53 pm
by Jose132
@Pedro Men, you have to do a slowly read for this problem, that formula is not completely right for this problem.
This is a little help from Matanzas city.
JoseA132 :P

Re: 1049 - Sum

Posted: Fri May 22, 2015 11:13 pm
by chicha
Hi fellows, first, I just use the formula (N*(N+1)/2), then, I read carefully and realize that all numbers don't fix in it, so, i made small "adjustment" for those several cases. I am still getting "Wrong answer" from the site, I really need help :-)
Thanks in advance

Re: 1049 - Sum

Posted: Sat May 23, 2015 5:55 pm
by HaZard
@chicha estuve mirando tu solución y el "ajuste" que le hiciste realmente no resuelve el problema pues la suma es de todos los números desde 1 hasta n

Re: 1049 - Sum

Posted: Sun May 24, 2015 12:21 am
by chicha
@HaZard gracias mil :D