记录编号 47692 评测结果 AAAAAAAAAA
题目名称 [NOIP 2010冲刺四]报数 最终得分 100
用户昵称 GravatarWJW0612 是否通过 通过
代码语言 Pascal 运行时间 0.002 s
提交时间 2012-11-02 20:12:54 内存使用 0.17 MiB
显示代码纯文本
program asdf;

var
  strNum : string;
  i, j, first, current, pointSite, decimalLength : integer;
  readway : array[0..1000] of char;
  readint : array[0..30] of char;
  isDecimal : boolean;

procedure openfile;

begin           //procedure openfile
  assign( input, 'readrule.in' );
  assign( output, 'readrule.out' );
  reset( input );
  rewrite( output );
end;            //procedure openfile

procedure closefile;

begin           //procedure closefile
  close( input );
  close( output );
end;            //procedure closefile

function getGread( a : integer ) : string;

begin          //function returnGread
  case a of
    0 : exit( '' );
    1 : exit( 'W' );
    2 : exit( 'Y' );
  end;
end;           //function returnGread

function getstatus( a : integer ) : string;

var
  temp : integer;

begin          //function getstatus
  temp := a mod 4;
  if a mod 4 = 0 then
    temp := 4;
  case temp of
    1 : exit( '' );
    2 : exit( 'S' );
    3 : exit( 'B' );
    4 : exit( 'Q' );
  end;
end;           //function getstatus

function thisIsDecimal( p_strNum : string ) : boolean;

var
  i : integer;

begin          //function isDecimal
  for i := 1 to length( p_strNum ) do
    if p_strNum[i] = '.' then
      begin
        pointSite := i;
        exit( true );
      end;
  exit( false );
end;           //function isDecimal

begin          //the main

  openfile;

  read( strNum );
  isDecimal := false;
  if strNum[1] = '-' then
    begin
      write( 'F' );
      delete( strNum, 1, 1 );
    end;
  if strNum[1] = '+' then
    delete( strNum, 1, 1 );
  while ( strNum[1] = '0' ) and ( strNum[2] <> '.' ) and ( strNum <> '' )  do
    delete( strNum, 1, 1 );
  if thisIsDecimal( strNum ) then
    begin
      isDecimal := true;
      while strNum[ length( strNum ) ] = '0' do
        delete( strNum, length( strNum ), 1 );
      if strNum[ length( strNum ) ] = '.' then
        delete( strNum, length( strNum ), 1 );
    end;

  current := 0;
  if isDecimal then
    begin
      for i := length( strNum ) downto pointSite + 1 do
        begin
          inc( current );
          readway[current] := strNum[i];
        end;
      inc( current );
      readway[current] := 'D';
      delete( strNum, pointSite, length( strNum ) - pointSite + 1 );
    end;
  decimalLength := current;

  if length( strNum ) = 1 then
    begin
      write( '0' );
      for i := decimalLength downto 1 do
        write( readway[i] );
      exit;
    end;

  repeat
    write( strNum[1] );
    if strNum[1] <> '0' then
      write( getstatus( length( strNum ) ) )
    else
      begin
        while ( strNum[1] = '0' ) and ( strNum <> '' ) do delete( strNum, 1, 1 );
        insert( '0', strNum, 1 );
      end;
    if length( strNum ) mod 4 - 1 = 0 then
      write( getgread( length( strNum ) div 4 ) );
    delete( strNum, 1, 1 );
  until strNum = '';
  for i := decimalLength downto 1 do
    write( readway[i] );

  closefile;

end.              //the main