【题解】洛谷P1603斯诺登的密码 字符串+map+打表

题目链接
直接打表吧……

#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define _rep(i,a,b) for(int i=(a);i<=(b);i++)
map<string,int>mp;
int num[110];
bool cmp(const int&a,const int&b){return a>b;}
int main()
{
    //freopen("in.txt","r",stdin);
    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["both"]=2;
    mp["another"]=1;
    mp["first"]=1;
    mp["second"]=2;
    mp["third"]=3;
    string a;
    int tp=0;   
    _rep(i,0,5)
    {
        cin>>a;
        if(mp.find(a)!=mp.end())num[tp++]=mp[a]*mp[a]%100;
    }
    sort(num,num+tp,cmp);
    ll ans=0;
    _rep(i,0,5)
    {
        ll tmp=1;
        _rep(j,1,i<<1)tmp*=10;
        ans+=tmp*num[i];
    }
    printf("%lld\n",ans);
    return 0;
}

你可能感兴趣的:(洛谷,map,字符串,打表)