usaco 2.2 preface 2008.6.20

usaco 2.2 preface 2008.6.20

{

ID:

PROG: preface

LANG: PASCAL

}

program p_preface;

const z:array[1..7]ofchar=('I','V','X','L','C','D','M');

var x:array[1..3000,0..5]of longint;

     f1,f2:text;

     ii,n,i,j:longint;

     a:array[1..7]of longint;

procedure put;

begin

x[3000,0]:=3;x[3000,1]:=7;x[3000,2]:=7;x[3000,3]:=7;

x[2000,0]:=2;x[2000,1]:=7;x[2000,2]:=7;

x[1000,0]:=1;x[1000,1]:=7;

x[900,0]:=2;x[900,1]:=5;x[900,2]:=7;

x[800,0]:=4;x[800,1]:=5;x[800,2]:=5;x[800,3]:=5;x[800,4]:=6;

x[700,0]:=3;x[700,1]:=5;x[700,2]:=5;x[700,3]:=6;

x[600,0]:=2;x[600,1]:=5;x[600,2]:=6;

x[500,0]:=1;x[500,1]:=6;

x[400,0]:=2;x[400,1]:=5;x[400,2]:=6;

x[300,0]:=3;x[300,1]:=5;x[300,2]:=5;x[300,3]:=5;

x[200,0]:=2;x[200,1]:=5;x[200,2]:=5;

x[100,0]:=1;x[100,1]:=5;

x[90,0]:=2;x[90,1]:=3;x[90,2]:=5;

x[80,0]:=4;x[80,1]:=4;x[80,2]:=3;x[80,3]:=3;x[80,4]:=3;

x[70,0]:=3;x[70,1]:=4;x[70,2]:=3;x[70,3]:=3;

x[60,0]:=2;x[60,1]:=3;x[60,2]:=4;

x[50,0]:=1;x[50,1]:=4;

x[40,0]:=2;x[40,1]:=3;x[40,2]:=4;

x[30,0]:=3;x[30,1]:=3;x[30,2]:=3;x[30,3]:=3;

x[20,0]:=2;x[20,1]:=3;x[20,2]:=3;

x[10,0]:=1;x[10,1]:=3;

x[9,0]:=2;x[9,1]:=1;x[9,2]:=3;

x[8,0]:=4;x[8,1]:=2;x[8,2]:=1;x[8,3]:=1;x[8,4]:=1;

x[7,0]:=3;x[7,1]:=2;x[7,2]:=1;x[7,3]:=1;

x[6,0]:=2;x[6,1]:=2;x[6,2]:=1;

x[5,0]:=1;x[5,1]:=2;

x[4,0]:=2;x[4,1]:=1;x[4,2]:=2;

x[3,0]:=3;x[3,1]:=1;x[3,2]:=1;x[3,3]:=1;

x[2,0]:=2;x[2,1]:=1;x[2,2]:=1;

x[1,0]:=1;x[1,1]:=1;

end;

procedure find(y:longint);

var i:longint;

begin

  fori:=1 to x[y,0] do

    inc(a[x[y,i]]);

end;

procedure deal(t:longint);

varu,p:string;l,m,i,k,code,h:longint;w:char;

begin

 u:='1';

 str(t,p);l:=length(p);

  fori:=1 to l-1 do u:=u+'0';val(u,k,code);

  fori:=1 to l-1 do

     begin  w:=p[i];val(w,m,code);

                h:=m*k;if h<>0 then find(h);

                k:=k div 10;

     end;

     if p[l]<>'0' then begin val(p[l],m,code);find(m);end;

 end;

{----------------------------------------------------}

begin

assign(f1,'preface.in');reset(f1);

assign(f2,'preface.out');rewrite(f2);

read(f1,n);fillchar(a,sizeof(a),0);

put;

for ii:=1 to n do

  deal(ii);

for i:=1 to 7 do

  ifa[i]<>0 then writeln(f2,z[i],' ',a[i]);

close(f1);

close(f2);

end.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值