10523 - Very Easy !!!
Moderator: Board moderators
10523 - Very Easy !!!
I got WA. Help me!
I think my WA because of output
My test input:
3 3
4 4
0 100
1 100
19 50
19 150
My test output:
1.020000E+02
1.252000E+03
0.000000E+00
5.050000E+03
4.567182E+65
1.029086E+194
Am I right?
Thank you.
I think my WA because of output
My test input:
3 3
4 4
0 100
1 100
19 50
19 150
My test output:
1.020000E+02
1.252000E+03
0.000000E+00
5.050000E+03
4.567182E+65
1.029086E+194
Am I right?
Thank you.
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
[pascal]program p10523;
var
n,a:integer;
sum,power:array[0..19,1..150] of double;
begin
//precalculate
for a:=0 to 19 do begin
sum[a,1]:=a;
power[a,1]:=a;
for n:=2 to 150 do begin
power[a,n]:=a*power[a,n-1];
sum[a,n]:=sum[a,n-1]+n*power[a,n];
end;
end;
while not eof do begin
if eoln then begin readln; continue; end; //skip empty lines
readln(n,a);
writeln(sum[a,n]); //regular double format ?!?
end;
end.[/pascal]
What is wrong? I get WA whatever I try.
Is it the 'regular double format'? The problem has a special judge, so I suppose it accepts the 'regular' Pascal double format.
Is it precision?
Please anybody, help me...
var
n,a:integer;
sum,power:array[0..19,1..150] of double;
begin
//precalculate
for a:=0 to 19 do begin
sum[a,1]:=a;
power[a,1]:=a;
for n:=2 to 150 do begin
power[a,n]:=a*power[a,n-1];
sum[a,n]:=sum[a,n-1]+n*power[a,n];
end;
end;
while not eof do begin
if eoln then begin readln; continue; end; //skip empty lines
readln(n,a);
writeln(sum[a,n]); //regular double format ?!?
end;
end.[/pascal]
What is wrong? I get WA whatever I try.
Is it the 'regular double format'? The problem has a special judge, so I suppose it accepts the 'regular' Pascal double format.
Is it precision?
Please anybody, help me...
-
- Guru
- Posts: 647
- Joined: Wed Jun 26, 2002 10:12 pm
- Location: Hong Kong and New York City
- Contact:
Code: Select all
sum[a,n-1]+n*power[a,n];
but basically:
for say,
3x^3 + 2x^2 + x,
I calculate it like this:
x ( 1 + x ( 2 + 3 ( x ) ) )
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
Translated the program to C and got accepted...
I wonder how the other Pascal programmers that got AC managed to get the same output as the standard C printf("%E\n",sum).
But I think the judges should accept the standard Pascal writeln(sum) (although it has a different output format) to make it a fair challenge for everybody.
To paraphrase Observer's tag line: "~~~ An ANGRY Pascal Programmer ~~~"
I wonder how the other Pascal programmers that got AC managed to get the same output as the standard C printf("%E\n",sum).
But I think the judges should accept the standard Pascal writeln(sum) (although it has a different output format) to make it a fair challenge for everybody.
To paraphrase Observer's tag line: "~~~ An ANGRY Pascal Programmer ~~~"
Yes I sometimes think that the online judge is somewhat unfair towards Pascal users. You see, in the judge input there are always trailing spaces, blank lines, leading blanks etc...
Moreover, I don't understand why the use of "seekeoln" and "seekeof" functions are restricted. It makes us difficult to handle the input spacing problems......![:cry:](./images/smilies/icon_cry.gif)
Moreover, I don't understand why the use of "seekeoln" and "seekeof" functions are restricted. It makes us difficult to handle the input spacing problems......
![:cry:](./images/smilies/icon_cry.gif)
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
little joey, if you really want to get ACC with your Pascal code, try this:
[pascal] while not eof do begin
readln(n,a);
str(sum[a,n], st);
val(copy(st,1,pos('.',st)+6),r,a); (** Rounding by hand
**)
if st[pos('.',st)+7] > '4'
then r := r + 0.000001;
writeln(r:0:6,copy(st,pos('E',st),5))
end;[/pascal]
P.S. Yes I know it's very brute-force......![:D](./images/smilies/icon_biggrin.gif)
P.S.2 I couldn't understand why I can't get ACC by [pascal]writeln(sum[a,n]:14);[/pascal]
[pascal] while not eof do begin
readln(n,a);
str(sum[a,n], st);
val(copy(st,1,pos('.',st)+6),r,a); (** Rounding by hand
![:D](./images/smilies/icon_biggrin.gif)
if st[pos('.',st)+7] > '4'
then r := r + 0.000001;
writeln(r:0:6,copy(st,pos('E',st),5))
end;[/pascal]
P.S. Yes I know it's very brute-force......
![:D](./images/smilies/icon_biggrin.gif)
P.S.2 I couldn't understand why I can't get ACC by [pascal]writeln(sum[a,n]:14);[/pascal]
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
It's the way Free Pascal rounds and displays.
For n=13, a=3 the exact answer is 29893557,
but Free Pascal:[pascal]writeln(sum[3,13]:14);[/pascal]displays " 2.989355E+007" with a leading space and rounding down,
while GCC:[c]prinf("%E\n",sum[3][13]);[/c]displays "2.989356E+07".
As your clever little code snippet shows, the special judge accepts the extra leading zero in the exponent and the extra space, but refuses to accept the rounding down.
IMHO the judge _should_ accept the standard output from Free Pascal, because it's their choice to use it for their compiler. In an ideal world, getting accepted should be completely compiler independent, although I admit that that is virtualy impossible.
Last year they replaced the GPC compiler with Free Pascal, which made 80% of my submitted code uncompilable. Also we lost the runtime error reporting, which is a great asset while trying to get your code AC, and which is available in C and C++. I wrote about this several times in this board, but somehow the judges choose to ignore my complaints (I know they are very busy, but they could at least tell us that they are...).
On my sad days, I think that UVA only added Pascal and JAVA so that it looks good on the main page. The real focus is on C and C++, the languages for the elite.
On my happy days, I see getting accepted in Pascal as an extra challenge and like to beat them C-sissies, with their built in functions and easy i/o. After all, I'm in it for the fun, and I'm getting loads of it![:wink:](./images/smilies/icon_wink.gif)
For n=13, a=3 the exact answer is 29893557,
but Free Pascal:[pascal]writeln(sum[3,13]:14);[/pascal]displays " 2.989355E+007" with a leading space and rounding down,
while GCC:[c]prinf("%E\n",sum[3][13]);[/c]displays "2.989356E+07".
As your clever little code snippet shows, the special judge accepts the extra leading zero in the exponent and the extra space, but refuses to accept the rounding down.
IMHO the judge _should_ accept the standard output from Free Pascal, because it's their choice to use it for their compiler. In an ideal world, getting accepted should be completely compiler independent, although I admit that that is virtualy impossible.
Last year they replaced the GPC compiler with Free Pascal, which made 80% of my submitted code uncompilable. Also we lost the runtime error reporting, which is a great asset while trying to get your code AC, and which is available in C and C++. I wrote about this several times in this board, but somehow the judges choose to ignore my complaints (I know they are very busy, but they could at least tell us that they are...).
On my sad days, I think that UVA only added Pascal and JAVA so that it looks good on the main page. The real focus is on C and C++, the languages for the elite.
On my happy days, I see getting accepted in Pascal as an extra challenge and like to beat them C-sissies, with their built in functions and easy i/o. After all, I'm in it for the fun, and I'm getting loads of it
![:wink:](./images/smilies/icon_wink.gif)
Oic... I've never noticed that... But why is it so???little joey wrote:It's the way Free Pascal rounds and displays.
Pascal is great. It's the judge system which makes us feel bad...
![:(](./images/smilies/icon_frown.gif)
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
10523 - WA after rejudgement
Could anyone tell me what should be wrong with this problem ?
I've got WA after rejudgement, so I have one question:
Is this true, that for input
output is exactly
?????
I use simple DP to calculate answer, and I think that all values are correct ...
Best regards
DM
I've got WA after rejudgement, so I have one question:
Is this true, that for input
Code: Select all
150 15
Code: Select all
41642470296774462562792725985031884205969838044105091368779920844033177704061607491770151984953636682503436650913970981305172726267418523206995220099298301053694354332223230478715
I use simple DP to calculate answer, and I think that all values are correct ...
Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
This is really strange ....
I think that this values which I compute are correct, but I see that something strange was happened with IO ...
Why only one person after rejudgement gave Accepted ??
Best regards
DM
I think that this values which I compute are correct, but I see that something strange was happened with IO ...
Why only one person after rejudgement gave Accepted ??
Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)