|
|
back to boardWHY WA on Test 5??? I tried to read till EOL, till incorect symbol. What's wrong here? program p1104; var i,Max,Summa,Number:longint; c:char; FoundSolution:boolean; begin Summa := 0; Max := 1; while True do begin read(c); if c in ['0'..'9'] then Number := Ord(c) - Ord('0') else if c in['A'..'Z'] then Number := Ord(c) - Ord('A') + 10 else break; Summa := Summa + Number; if Number > Max then Max := Number; end; FoundSolution := False; for i:=Max to 36 do if Summa mod i = 0 then begin FoundSolution := True; break; end; if FoundSolution then writeln(i+1) else writeln('No Solution.'); end. Re: WHY WA on Test 5??? It seems must be for i:=Max to 35 do... (but I get also WA on test 5) Letter Z can't be used in a string, otherwise we'll get 37 - base system (k=37). And in a problem we have 2 <= k <= 36 Re: WHY WA on Test 5??? The 's' in 'No solution.' is not a uppercase latin letter. |
|
|