链接:https://ac.nowcoder.com/acm/contest/316/C
来源:牛客网
题解:模拟;
主要用到stringstream,可以分割字符串,然后还有一个换行读入,有了这些比较好处理一些,先看这段代码(简单解释)。
string one;
while(getline(cin,one)){
stringstream a;
a<<one;
string ch;
while(a>>ch){
cout<<ch<<endl;
}
}
输入 one two three four five 输入 每一个单词
代码
#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
using namespace std;
typedef long long ll;
map<string,int>mp;
void init(){
mp["zero"]=0;
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;
}
int main(){
/*string one;
while(getline(cin,one)){
stringstream a;
a<<one;
string ch;
while(a>>ch){
cout<<ch<<endl;
}
}*/
init();
string one,two;
while(getline(cin,one)){//换行读入
getline(cin,two);
stringstream a;
stringstream b;//分割字符串
a<<one;//写入
b<<two;//写入
string ch;
ll ansone=0;
while(a>>ch){
ansone=ansone*16+mp[ch];
//cout<<ansone<<endl;
}
ll anstwo=0;
while(b>>ch){
anstwo=anstwo*16+mp[ch];
}
cout<<ansone*anstwo<<endl;
}
return 0;
}
编辑器的选择
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
我们有许多同学程序都不会写却已经掌握了 42 种编辑器的使用,并要求裁判提供它们。然而裁判太菜了,并没有安装包。裁判只有两个英文字母串表示的数,请问它们的 16 进制表示的乘积是多少。
输入描述:
多组数据,每一组数据包含两行,每一行表示一个 16 进制数,每一个英文单词以空格分隔,每一行的最后一个
单词后无空格。每一行以 '\n' 结尾 。
10 ~ 15 的英文单词表示十六进制中的 A-F 。
输出描述:
对于每组数据,输出两个数的乘积,以 10 进制表示。保证乘积不超过107
示例1
输入
复制
one two
two
输出
复制
36
说明
备注:
为了照顾专心研究编辑器而没有好好学外语的同学,我们给出 0~15 的英文单词:
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