zoukankan      html  css  js  c++  java
  • 斯诺登的密码

    题意

    找出句子中所有用英文表示的数字(≤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.

  • 相关阅读:
    行为型模式之Template Method模式
    【翻译】无需安装Python,就可以在.NET里调用Python库
    SciSharpCube:容器中的SciSharp,.NET机器学习开箱即用
    [翻译] NumSharp的数组切片功能 [:]
    C#
    API做翻页的两种思路
    C#相等性
    C#相等性
    SpringBoot进阶教程(五十八)整合Redis之Sentinel哨兵模式
    org.springframework.cache.interceptor.SimpleKey cannot be cast to java.lang.String
  • 原文地址:https://www.cnblogs.com/YYC-0304/p/9500198.html
Copyright © 2011-2022 走看看