超级小弱鸡抄都抄不会

P1603 斯诺登的密码

Calmingjucie @ 2024-10-06 20:38:28

照评论区大佬的思路自己写了一遍只有20分,能帮我看看哪里错了么


#include<iostream>
#include<algorithm>
using namespace std;
string a[30]={"","one","two","three","four","five","six","seven",
"eight","nine","ten","elven","twelve","thirteen","fourteen","fifteen",
"sixteen","seventeen","eighteen","nineteen","twenty","a","both",
"another","first","second","third"};
int b[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};
int k,c[10];

int main()
{
    for(int i=1;i<=6;i++){
        string x;
        cin>>x;
        for(int j=1;j<=26;j++){
            if(a[i]==x){
                c[++k]=b[j];
                break;
            }
        }
    }
    if(k==0){
        cout<<0<<endl;
        return 0;
    }
    sort(c+1,c+k+1);
    for(int i=1;i<=k;i++){
        if(i!=1&&c[i]<10) cout<<0;
        cout<<c[i];
    }
    cout<<endl;
    return 0;
}
 ``` ```

by yuwenxiang1017 @ 2024-10-06 21:39:20

样例都过不了?


by aszxqw @ 2024-10-12 14:55:10

#include<bits/stdc++.h>
using namespace std;
const int N=50;
int st[N];
map<string,int> mp; 
int main(){
    mp["one"]=1,mp["two"]=2,mp["three"]=3,mp["four"]=4,mp["five"]=5,mp["six"]=6,mp["seven"]=7,mp["eight"]=8,mp["nine"]=9,mp["ten"]=10,mp["eleven"]=11,mp["twelve"]=12,mp["thirteen"]=13,mp["fourteen"]=14,mp["fifteen"]=15,mp["sixteen"]=16,mp["seventeen"]=17,mp["eighteen"]=18,mp["nineteen"]=19,mp["twenty"]=20,mp["a"]=1,mp["second"]=2,mp["third"]=3,mp["both"]=2,mp["another"],mp["first"]=1;
    string s;
    int t=0;
    for(int i=1;i<=6;i++){
        cin>>s;
        int x=mp[s];
        if(x){
            int k=(x*x)%100;
            if(k==0) continue;
            st[++t]=k;
        }   
    }
    sort(st+1,st+t+1);
    cout<<st[1];
    for(int i=2;i<=t;i++){
        if(st[i]<10)cout<<0;
        cout<<st[i];
    }
    return 0;
}

|