#4#5未过求助,60分

P1603 斯诺登的密码

splendid_followers @ 2021-04-23 16:55:27

本地编译与.out一样但是测评显示too short

#include<bits/stdc++.h>
using namespace std;
char db[30][100]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty","a","both","another","first","second","third"};
int dbs[30]={0,1,4,9,16,25,36,49,64,81,00,21,44,69,96,25,56,89,24,61,0,1,4,1,1,4,9};
char s[6][100],ch[100];
int mh[6],top=0;
int main()
{
    for(int i=0;i<6;i++)
    {
        cin>>s[i];
        if(i==5)
        {
            int a=strlen(s[i]);
            s[i][a-1]=0;
        }
        for(int j=0;j<30;j++)
        {
            if(strcmp(s[i],db[j])==0)
            {
                mh[top]=dbs[j];
                top++;
            }
        }
    }
    bool wl=0;
    bool ys=0;
    for(int i=0;i<top;i++)
    {
        int max=101,maxi;
        for(int j=0;j<top;j++)
        {
            if(mh[j]<=max)
            {
                max=mh[j];
                maxi=j;
            }
        }
        mh[maxi]=102;
        if(i==0&&max!=0)
        {
            ys=1;
            wl=1;
            cout<<max;
            continue;
        }
        if(max!=0&&wl==1)
        {
            if(max<10)
            {
                cout<<"0"<<max;
                ys=1;
                continue;
            }
            if(max>=10)
            {
                cout<<max;
                ys=1;
                continue;
            }
        }
        else
        {
            if(max!=0)
            {
                cout<<max;
                wl=1;
            }
        }

    }
    if(ys==0)
    {
        cout<<"0";
    }
}

by splendid_followers @ 2021-04-23 17:09:22

洛谷在线IDE出来的结果也和.out一样


by splendid_followers @ 2021-06-13 19:58:36

破案了,句子最后一个单词还有一个空格


|