325 - Identifying Legal Pascal Real Constants
Moderator: Board moderators
Please Help me everyone! 325 and 335!!!
Please give me the answer for problem number 325 and 335 in C Language! I really need it for my collegge assignment
Thank You
Thank You
Dear Andrew Baggio,
Why do you want just the answer ?
And after you get the answer, you can just submit it to Online Judge and get Accepted ?
Isn't that makes you feel satisfied (get Accepted with other person's answer) ?
Have you tried to make it by yourself ?
If you face any problems on 325, why don't you ask something about this problem on board, like deddy one and I will help you as far as I can, but not the answer, of course.
If you want, I can help you to send my AC exe file to you, and you can re-check your output with mine. Ok ?
I think ACM is the place where we can study together to improve our skill in programming, but not just a place to submit problems as many as possible. Isn't that right ?![:wink:](./images/smilies/icon_wink.gif)
Why do you want just the answer ?
And after you get the answer, you can just submit it to Online Judge and get Accepted ?
Isn't that makes you feel satisfied (get Accepted with other person's answer) ?
![:wink:](./images/smilies/icon_wink.gif)
Have you tried to make it by yourself ?
If you face any problems on 325, why don't you ask something about this problem on board, like deddy one and I will help you as far as I can, but not the answer, of course.
![:D](./images/smilies/icon_biggrin.gif)
If you want, I can help you to send my AC exe file to you, and you can re-check your output with mine. Ok ?
![:wink:](./images/smilies/icon_wink.gif)
I think ACM is the place where we can study together to improve our skill in programming, but not just a place to submit problems as many as possible. Isn't that right ?
![:wink:](./images/smilies/icon_wink.gif)
Dear deddy one,
You're right, e/E can only be used once like dot.
Have you got AC on this problem? If not, I'll give you another tips:
1. Using adjacent + or - means illegal (e.g: 6.5e--4 is illegal, +-1.34e9 is illegal but +3.6e13 is legal)
2. No space between real constant (e.g: 5 e 6 is illegal but 5e6 is legal)
3. Dot can't be placed before or after the real constant (e.g: .5e6 is illegal, 5e6. is illegal)
Good luck!![:D](./images/smilies/icon_biggrin.gif)
You're right, e/E can only be used once like dot.
Have you got AC on this problem? If not, I'll give you another tips:
1. Using adjacent + or - means illegal (e.g: 6.5e--4 is illegal, +-1.34e9 is illegal but +3.6e13 is legal)
2. No space between real constant (e.g: 5 e 6 is illegal but 5e6 is legal)
3. Dot can't be placed before or after the real constant (e.g: .5e6 is illegal, 5e6. is illegal)
Good luck!
![:D](./images/smilies/icon_biggrin.gif)
thx very much angga
I've found my tricky input
for future solver consider this input
123.e123123123123123123+123123123123123123123
is illegal
ps :
this problem must be faced with clear headed situation
don't try to code it under pressure like me, it can be a stress
full job
with almost the same logic thinking actually you can
try to solve 392 too (I got it AC on second submission)
in 325 I got more than 10 WA
well, actually not that same logic thinking , but in both
of my code for 325 and 392 need a lot of if's
(that's the similarity)
I've found my tricky input
for future solver consider this input
123.e123123123123123123+123123123123123123123
is illegal
ps :
this problem must be faced with clear headed situation
don't try to code it under pressure like me, it can be a stress
full job
with almost the same logic thinking actually you can
try to solve 392 too (I got it AC on second submission)
in 325 I got more than 10 WA
well, actually not that same logic thinking , but in both
of my code for 325 and 392 need a lot of if's
(that's the similarity)
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
I've got AC by using Dominik's methodDominik Michniewski wrote:Try this method:
only same states are allowed, also create biggest figure of good constant, it is: x[.(x)+][{E|e}(x)+]
where (x)+ means one or more digit
[x] means optional part of expression
{x|y} means one and exactly one of specified in brackets values
![:lol:](./images/smilies/icon_lol.gif)
But " x[.(x)+][{E|e}(x)+] " need to change into these segments :
" [+ or - or empty] [(x)+.(x)+] [E or e] [+ or - or empty] [(x)+] "
I succeeded at the second try.
Good luck
![:wink:](./images/smilies/icon_wink.gif)
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
-
- Learning poster
- Posts: 57
- Joined: Wed Dec 10, 2003 7:32 pm
- Location: Russia, Saint-Petersburg
325 [Pascal] Why WA?
I don`t know why I get WA.
Here some inputs for this problem. Maybe I have incorrect output?!
Help me PLEASE!!!
INPUT
OUTPUT
Here some inputs for this problem. Maybe I have incorrect output?!
Help me PLEASE!!!
INPUT
Code: Select all
1E1
1e1
1E
1EE1
1 E1
.1E1
1E.1
1E1.1
++1E1
1E--1
1.1.1E1
abcd
1
1.1
0e-0
*
Code: Select all
1E1 is legal.
1e1 is legal.
1E is illegal.
1EE1 is illegal.
1 E1 is illegal.
.1E1 is illegal.
1E.1 is illegal.
1E1.1 is illegal.
++1E1 is illegal.
1E--1 is illegal.
1.1.1E1 is illegal.
abcd is illegal.
1 is illegal.
1.1 is legal.
0e-0 is legal.
-
- Learning poster
- Posts: 57
- Joined: Wed Dec 10, 2003 7:32 pm
- Location: Russia, Saint-Petersburg
Hello Sanya! Thank you for reply.
Here my code for this problem:
[pascal]program acm325;
var n: integer;
s, l, i: string;
f: boolean;
begin
{ assign(input, 'input.txt');
reset(input);
assign(output, 'output.txt');
rewrite(output);}
l:=' is legal.';
i:=' is illegal.';
while not eof do begin
readln(s);
while s[1]=' ' do delete(s, 1, 1);
while s[length(s)]=' ' do delete(s, length(s), 1);
if s='*' then break;
f:=false;
write(s);
if (s[1]='+') or (s[1]='-') then delete(s, 1, 1);
while (s[1]>='0') and (s[1]<='9') and (s<>'') do begin delete(s, 1, 1); f:=true; end;
if (not f) or (s='') then begin writeln(i); continue; end;
f:=false;
if s[1]='.' then begin
delete(s, 1, 1);
if (s[1]<'0') or (s[1]>'9') then begin writeln(i); continue; end;
while (s[1]>='0') and (s[1]<='9') and (s<>'') do begin delete(s, 1, 1); f:=true; end;
end;
if s='' then begin writeln(l); continue; end;
if (s[1]='e') or (s[1]='E') then delete(s, 1, 1); f:=true;
if (not f) or (s='') then begin writeln(i); continue; end;
f:=true;
if (s[1]='-') or (s[1]='+') then delete(s, 1, 1);
for n:=1 to length(s) do if not ((s[n]>='0') and (s[n]<='9')) then f:=false;
if f then writeln(l) else writeln(i);
end;
end.
[/pascal]
So how you can see, I look into string from begin and to end according to orders.
Here my code for this problem:
[pascal]program acm325;
var n: integer;
s, l, i: string;
f: boolean;
begin
{ assign(input, 'input.txt');
reset(input);
assign(output, 'output.txt');
rewrite(output);}
l:=' is legal.';
i:=' is illegal.';
while not eof do begin
readln(s);
while s[1]=' ' do delete(s, 1, 1);
while s[length(s)]=' ' do delete(s, length(s), 1);
if s='*' then break;
f:=false;
write(s);
if (s[1]='+') or (s[1]='-') then delete(s, 1, 1);
while (s[1]>='0') and (s[1]<='9') and (s<>'') do begin delete(s, 1, 1); f:=true; end;
if (not f) or (s='') then begin writeln(i); continue; end;
f:=false;
if s[1]='.' then begin
delete(s, 1, 1);
if (s[1]<'0') or (s[1]>'9') then begin writeln(i); continue; end;
while (s[1]>='0') and (s[1]<='9') and (s<>'') do begin delete(s, 1, 1); f:=true; end;
end;
if s='' then begin writeln(l); continue; end;
if (s[1]='e') or (s[1]='E') then delete(s, 1, 1); f:=true;
if (not f) or (s='') then begin writeln(i); continue; end;
f:=true;
if (s[1]='-') or (s[1]='+') then delete(s, 1, 1);
for n:=1 to length(s) do if not ((s[n]>='0') and (s[n]<='9')) then f:=false;
if f then writeln(l) else writeln(i);
end;
end.
[/pascal]
So how you can see, I look into string from begin and to end according to orders.
-
- New poster
- Posts: 39
- Joined: Fri Nov 14, 2003 11:18 pm
- Location: Riga, Latvia
- Contact:
You don't have to set "flag:=true" in "if s[1]='.' then" section.
Consider this input: 123.456+789
Your prog reaches '.', removes digits 456 and has it's flag happily set to true. It skips the following 3 "ifs", sees the + sign, removes 789 and thinks everything's OK, while it is not.![:)](./images/smilies/icon_smile.gif)
PS: Sorry, I missed the fact that there's no "begin-end" when you check if s[1] is in ['e', 'E'], so ignore the above stated.
Still, your prog fails on 123.456+789.
Consider this input: 123.456+789
Your prog reaches '.', removes digits 456 and has it's flag happily set to true. It skips the following 3 "ifs", sees the + sign, removes 789 and thinks everything's OK, while it is not.
![:)](./images/smilies/icon_smile.gif)
PS: Sorry, I missed the fact that there's no "begin-end" when you check if s[1] is in ['e', 'E'], so ignore the above stated.
![:oops:](./images/smilies/icon_redface.gif)
Last edited by Aleksandrs Saveljevs on Fri Dec 19, 2003 6:48 pm, edited 2 times in total.