program AI; var nZad:integer; cod:char; iii:integer; flag:array [1..3] of boolean; str:string; n,n1:integer; dig:string; p:array [1..3] of real; nDig:integer; c:integer; f:text; begin Assign(f,'ai.in'); Reset(f); ReadLn(f,nZad); for n:=1 to nZad do begin ReadLn(f,str); for iii:=1 to 3 do flag[iii]:=false;; for n1:=1 to length(str) do begin if str[n1]='=' then begin cod:=str[n1-1]; case cod of 'P': begin nDig:=1; flag[1]:=true; end; 'U': begin nDig:=2; flag[2]:=true; end; 'I': begin nDig:=3; flag[3]:=true; end; end; dig:=''; inc(n1); while ((str[n1]<='9')and(str[n1]>='0'))or(str[n1]='.') do begin dig:=dig+str[n1]; inc(n1); end; Val(dig,p[nDig],c); case str[n1] of 'm': p[nDig]:=p[nDig]/1000.; 'k': p[nDig]:=p[nDig]*1000.; 'M': p[nDig]:=p[nDig]*1000000.; end; end; end; if not flag[1] then cod:='P'; if not flag[2] then cod:='U'; if not flag[3] then cod:='I'; case cod of 'P': begin WriteLn('Задача #',n); WriteLn('P=',p[2]*p[3]:3:2,'W'); end; 'U': begin WriteLn('Задача #',n); WriteLn('U=',(p[1]/p[3]):3:2,'V'); end; 'I': begin WriteLn('Задача #',n); WriteLn('I=',(p[1]/p[2]):3:2,'A'); end; end; WriteLn; end; Close(f); end.