斯诺登的密码

题意

找出句子中所有用英文表示的数字(≤20),将这些数字平方后%100,如00,05,11,19,86,99。把这些两位数按数位排成一行,组成一个新数,如果开头为0,就去0。找出所有排列方法中最小的一个数,即为密码。


分析

先计算出每一个数字的平方,不过在放进数组里时,只放两位。

如1的平方是1,放进数组里时则变成01。

如10的平方是100,放进数组里时则变成00。

最后排序再输出。


var
i,j:longint;
a:array[0..20]of string;
s,zfc,sz:string;
dz:int64;

begin
    read(s);
    dz:=0;
    repeat
         sz:=copy(s,1,pos(' ',s)-1);
         if (sz='one')or(sz='One')or(sz='a')or(sz='another')or(sz='first') then
         begin
             inc(dz);
             a[dz]:='01';
         end else
         if (sz='two')or(sz='Two')or(sz='both')or(sz='second') then
         begin
             inc(dz);
             a[dz]:='04';
         end else
         if (sz='three')or(sz='Three')or(sz='third') then
         begin
             inc(dz);
             a[dz]:='09';
         end else
         if (sz='four')or(sz='Four') then
         begin
             inc(dz);
             a[dz]:='16';
         end else
         if (sz='five')or(sz='Five') then
         begin
             inc(dz);
             a[dz]:='25';
         end else
         if (sz='six')or(sz='Six') then
         begin
             inc(dz);
             a[dz]:='36';
         end else
         if (sz='seven')or(sz='Seven') then
         begin
             inc(dz);
             a[dz]:='49';
         end else
         if (sz='eight')or(sz='Eight') then
         begin
             inc(dz);
             a[dz]:='64';
         end else
         if (sz='nine')or(sz='Nine') then
         begin
             inc(dz);
             a[dz]:='81';
         end else
         if (sz='ten')or(sz='Ten') then
         begin
             inc(dz);
             a[dz]:='00';
         end else
         if (sz='eleven')or(sz='Eleven') then
         begin
             inc(dz);
             a[dz]:='21';
         end else
         if (sz='twelve')or(sz='Twelve') then
         begin
             inc(dz);
             a[dz]:='44';
         end else
         if (sz='thirteen')or(sz='Thirteen') then
         begin
             inc(dz);
             a[dz]:='69';
         end else
         if (sz='fourteen')or(sz='Fourteen') then
         begin
             inc(dz);
             a[dz]:='96';
        end else
        if (sz='fifteen')or(sz='Fifteen') then
         begin
             inc(dz);
             a[dz]:='25';
         end else
         if (sz='sixteen')or(sz='Sixteen') then
         begin
             inc(dz);
             a[dz]:='56';
         end else
         if (sz='seventeen')or(sz='Seventeen') then
         begin
             inc(dz);
             a[dz]:='89';
         end else
         if (sz='eighteen')or(sz='Eighteen') then
         begin
             inc(dz);
             a[dz]:='24';
         end else
         if (sz='nineteen')or(sz='Nineteen') then
         begin
             inc(dz);
             a[dz]:='61';
         end else
         if (sz='twenty')or(sz='Twenty') then
         begin
             inc(dz);
             a[dz]:='00';
        end;
         delete(s,1,pos(' ',s));
    until s[1]='.';
    for i:=1 to dz-1 do
    begin
        for j:=i+1 to dz do
        if a[i]>=a[j] then
        begin
            a[0]:=a[i];a[i]:=a[j];a[j]:=a[0];
        end;
    end;
    zfc:='';
    for i:=1 to dz do
    zfc:=zfc+a[i];
    val(zfc,dz);
    write(dz);
end.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值