Page 2 of 5

Posted: Wed Jan 08, 2003 11:10 am
by andrew10
[Can you send me the answer to me too??? Please!!!
Send on andrew_baggio_10@yahoo.com. I really need your help!

Thank You

Please Help me everyone! 325 and 335!!!

Posted: Wed Jan 08, 2003 11:14 am
by andrew10
Please give me the answer for problem number 325 and 335 in C Language! I really need it for my collegge assignment

Thank You

Posted: Fri Jan 10, 2003 3:13 am
by angga888
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) ? :wink:
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
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:

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:

Posted: Fri Jan 10, 2003 3:27 am
by angga888
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

Posted: Fri Jan 10, 2003 3:41 pm
by deddy one
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)

Posted: Fri Jan 10, 2003 4:02 pm
by Dominik Michniewski
Your input is off course illegal, and it's easy to deduce from input statement .... :)) this problem isn't involved with parsers of expressions, but it must check properly of constant :)))

So if whole input line cannot be constant - it's not constant :D

Regards
Dominik

Posted: Fri Jan 10, 2003 4:10 pm
by angga888
Have you tried to solve the problem by yourself ???

Posted: Fri Jan 10, 2003 4:14 pm
by angga888
Have you tried to solve the problem by yourself ??? :wink:
Tried it first, if you have any question, just put it on board.

Regards.

Posted: Wed Sep 03, 2003 4:14 pm
by InOutMoTo
Dominik 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
I've got AC by using Dominik's method :lol:

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:

Posted: Thu Sep 04, 2003 9:05 am
by Dominik Michniewski
Of course - I forget about signs in expression.... Sorry

Best regards
DM

325 [Pascal] Why WA?

Posted: Thu Dec 18, 2003 4:02 pm
by pavelph
I don`t know why I get WA.
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 
* 
OUTPUT

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.

Posted: Fri Dec 19, 2003 12:54 am
by Sanya
Hello! I solved this problem. So maybe I can help you, but I need to see your source. Your output seems to be correct.

Posted: Fri Dec 19, 2003 11:17 am
by pavelph
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.

Posted: Fri Dec 19, 2003 1:02 pm
by Aleksandrs Saveljevs
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. :)

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: Still, your prog fails on 123.456+789.

Posted: Fri Dec 19, 2003 6:04 pm
by Sanya
Try to replace line
[pascal]
if (s[1]='e') or (s[1]='E') then delete(s, 1, 1); f:=true;
[/pascal]
with following:
[pascal]
if (s[1]='e') or (s[1]='E') then begin delete(s, 1, 1); f:=true; end
else begin writeln(i); continue; end;
[/pascal]