C++,luogu,P1603 斯诺登的密码

//luogu,P1603 斯诺登的密码
#include <iostream>
#include <set>
#include <string>
#include <map>
/*
one two three four five six seven eight nine ten 
eleven twelve thirteen fourteen fifteen sixteen 
seventeen eighteen nineteen twenty

a both another(1) first second third
*/
int wordToInteger(std::string str){
    std::map<std::string,int> wordToIntegerMap={
        {"zero",0},
        {"one",1},
        {"two",2},
        {"three",3},
        {"four",4},
        {"five",5},
        {"six",6},
        {"seven",7},
        {"eight",8},
        {"nine",9},
        {"ten",10},
        {"eleven",11},
        {"twelve",12},
        {"thirteen",13},
        {"fourteen",14},
        {"fifteen",15},
        {"sixteen",16},
        {"seventeen",17},
        {"eighteen",18},
        {"nineteen",19},
        {"twenty",20},
        {"a",1},
        {"both",2},
        {"another",1},
        {"first",1},
        {"second",2},
        {"third",3}
    };
    return wordToIntegerMap[str];
}
int main(){
    std::multiset<int> nums;
    std::string str;
    while(std::cin>>str){
        int num=wordToInteger(str);
        num = num*num % 100;
        if(num!=0){
            nums.insert(num);
        }
    }
    if(nums.empty()){
        std::cout<<0;
        return 0;
    }
    auto it = nums.begin();
    std::cout<<*it;
    for(++it;it!=nums.end();++it){
        if(*it<10){
            std::cout<<0<<*it;
        }else{
            std::cout<<*it;
        }
    }
}
posted @ 2025-03-07 20:22  Kazuma_124  阅读(29)  评论(0)    收藏  举报