ZOJ - 2311 翻译英文数字

UniApp实现多端支付功能完整实现指南 支付业务流程多端支付实现安全性保障异常处理最佳实践支付基础知识多端支付实现统一支付封装安全性处理异常处理最佳实践根据具体业务场景选择合适的支付方式注重安全性和用户体验做好异常处理和日志记录持续优化和改进支付流程关注我,持续分享前端项目开发经验! 阅读详情

In this problem, you will be given one or more integers in English. Your task is to translate these numbers into their integer representation. The numbers can range from negative 999,999,999 to positive 999,999,999. The following is an exhaustive list of English words that your program must account for:

     negative, zero, one, two, three, four, five, six, seven, eight,
     nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen,
     seventeen, eighteen, nineteen, twenty, thirty, forty, fifty, sixty,
     seventy, eighty, ninety, hundred, thousand, million

Input

The input consists of several instances. Notes on input:

Negative numbers will be preceded by the word negative.

The word "hundred" is not used when "thousand" could be. For example, 1500 is written "one thousand five hundred", not "fifteen hundred".

The input is terminated by an empty line.

Output

The answers are expected to be on separate lines with a newline after each.

Sample Input

six
negative seven hundred twenty nine
one million one hundred one
eight hundred fourteen thousand twenty two

Sample Output

6
-729
1000101
814022




#include<iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <sstream>
using namespace std;



int main(){

    map<string, int> m;
    m["zero"] = 0;
    m["one"] = 1;
    m["two"] = 2;
    m["three"] = 3;
    m["four"] = 4;
    m["five"] = 5;
    m["six"] = 6;
    m["seven"] = 7;
    m["eight"] = 8;
    m["nine"] = 9;
    m["ten"] = 10;
    m["eleven"] = 11;
    m["twelve"] = 12;
    m["thirteen"] = 13;
    m["fourteen"] = 14;
    m["fifteen"] = 15;
    m["sixteen"] = 16;
    m["seventeen"] = 17;
    m["eighteen"] = 18;
    m["nineteen"] = 19;
    m["twenty"] = 20;
    m["thirty"] = 30;
    m["forty"] = 40;
    m["fifty"] = 50;
    m["sixty"] = 60;
    m["seventy"] = 70;
    m["eighty"] = 80;
    m["ninety"] = 90;

    string s1,s;
    while(getline(cin,s1) && s1!=""){
        istringstream is(s1);
        int gs = 0,b = 0,q = 0,bw = 0; //个十/百/千/百万
        bool flag = 0;
        while(is>>s){
            if(s == "hundred"){
                b = gs*100;
                gs = 0;
            }
            else if(s == "thousand"){
                q = (gs+b)*1000;
                gs = 0;
                b = 0;
            }
            else if(s == "million"){
                bw = (gs + b + q)*1000000;
                gs = 0;
                b = 0;
                q = 0;
            }
            else if(s == "negative")
                flag = 1;
            else
                gs += m[s];
        }
        if(flag)
            cout<<"-"<<gs+b+q+bw<<endl;
        else
            cout<<gs+b+q+bw<<endl;
    }
    return 0;

}


四个位置填一遍算一遍,每遍以出现量词结束,最后一遍可能没有量词,自己意会下。



腾讯会议+OBS虚拟摄像头:解决多人屏幕共享的终极指南(附常见问题排查) 本文详细介绍了如何利用OBS虚拟摄像头技术,解决腾讯会议中多人屏幕共享的痛点。通过将OBS作为视频混流中心,可以突破腾讯会议单屏共享的限制,实现多屏幕、多窗口内容的同步展示,并提升演示的专业度。文章涵盖了Windows与Linux双平台的配置步骤、高阶场景搭建以及常见问题(如黑屏、画中画)的排查方法,是团队协作与专业演示的实用指南。 阅读详情

相关推荐

5分钟搞定CST周期性结构仿真:共面波导色散曲线快速生成技巧

本文提供了一套在CST Studio Suite中快速仿真周期性结构并生成色散曲线的标准化流程。针对共面波导设计,重点解析了周期性边界条件的核心设置、本征模求解器(JDM算法)的优化技巧,以及通过参数扫描与后处理模板实现自动化,旨在帮助射频与微波工程师在5分钟内高效完成关键性能验证。

blue的专栏 1251

POJ - 3468 A Simple Problem with Integers

A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 156222 Accepted: 48325 Case Time Limit: 2000MS Description You have N integers, A1, A2, … , AN. You need to...

EIP_silly的博客 303

[捷稀 JCG Q30 Pro 刷机说明] 以刷入openwrt24.10为例

摘要: 本文详细介绍了捷稀JCG Q30 Pro路由器刷入OpenWrt 24.10系统的步骤。通过先刷入OpenWrt 23.05过渡固件,再升级Uboot,最后通过TFTP加载工厂镜像完成刷机。关键步骤包括解锁分区、刷写Uboot、进入恢复模式及配置网络。文章还提供了无线设置、Tailscale内网穿透等进阶命令,并附参考文档和固件下载链接。适用于有一定技术基础的玩家,需注意操作风险,严格按流程执行。

贤时间 7164

POJ2121题解(有借鉴)

POJ2121 Description In this problem, you will be given one or more integers in English. Your task is to translate these numbers into their integer representation. The numbers can range from negative 999,999,999 to positive 999,999,999. The following is an

Transquilizer的博客 630

(入门向)在Ubuntu22.04.3安装Matlab2021b,以及无法安装在当前目录下的解决办法(见最后)

还有这个/usr/local是只读状态,我试过sudo chmod..去改那个文件的读,结果还是安装不了,我不是这个默认路径,因为它文件夹还是只读,于是我在matlab2021b下创了一个bin,并选上。输入完成后,依次按y,因为里面有三个文件,他会让你确定3次密码,直接yyy跳过即可。你可能会遇到装不下的情况,这个软件占30g,可是你分配给虚拟机就剩10g。,于是我去Downloads下建了一个matlab2021b文件夹,果然好使,3).此时,会提示你输入密码,因为这个rar是有密码的,

harrype的博客 7295

雷电模拟器9.0最新过检测实战:从修改Build.prop到Xposed模块配置全流程

本文提供了一套针对雷电模拟器9.0的深度伪装实战方案,旨在绕过应用检测。内容涵盖从理解检测机制、获取Root权限、修改Build.prop等静态伪装,到利用Xposed/LSPosed框架进行运行时Hook的动态伪装全流程,帮助用户构建无痕的“真机”环境以稳定运行应用。

z4a5b6的博客 871

Inglish-Number Translator(含map做法)

In this problem, you will be given one or more integers in English. Your task is to translate these numbers into their integer representation. The numbers can range from negative 999,999,999 to positive 999,999,999. The following is an exhaustive list of E

准备23考研。不定期更新考研知识 464

使用再生龙还原镜像文件到硬盘

1. 把制作好的再生龙光盘插入需要的电脑,开机按F4使用再生龙启动2. 选择默认的:Clonezailla live(Default settings,VGA 800*600),然后等待几分钟 3. 选择语言:简体中文 4. 选择不修改键盘映射 5. 选择使用再生龙          6. 选择硬盘/分区(存到/来自)镜像文件,此选项既可以制作镜像,也可以恢复镜像。 7. 使用本机的分区     ...

weixin_42168893的博客 1万+

poj 2121 Inglish-Number Translator 将英文翻译成罗马数字

Inglish-Number TranslatorTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2822 Accepted: 1107<br />DescriptionIn this problem, you will be given one or more integers in English. Your task is to translate these numbers into their integer representa

kongming_acm的专栏 2353

华为OD统一考试 - 模拟消息队列(Java & Python& JS & C++ & C )

让我们来模拟一个消息队列的运作,有一个发布者和若干消费者,发布者会在给定的时刻向消息队列发送消息,

算法大师! 3519

专栏目录:Linux 内存管理子系统的进化——从 MM 到 HMM

专栏梳理了Linux内存管理子系统从经典MM到异构内存管理(HMM)的演进历程。内容分为六大部分:首先介绍经典MM基础,包括虚拟地址空间、页表、VMA等核心机制;其次分析MM通用框架如页表遍历、NUMA迁移等;然后探讨设备内存引入的关键技术,如ZONE_DEVICE和dev_pagemap;接着深入解析HMM核心机制及其与DMA的集成;随后通过多个实际驱动案例展示HMM应用;最后讨论大页支持等进阶主题。专栏采用"经典机制→问题→扩展方案"的三段式结构,帮助开发者理解Linux如何通过HMM实现设备内存管理。

图形/计算GPU的驱动与虚拟化技术分享园地 889

UVA486 English-Number Translator【递归+映射】

In this problem, you will be given one or more integers in English. Your task is to translate these numbers into their integer representation. The numbers can range from negative 999,999,999 to positi...

海岛Blog 1374

【Claude】Claude Code 子代理(Subagents)完全指南:多 AI 编排与并行任务管理

子代理是在独立上下文窗口特性主代理子代理上下文窗口与你对话的主上下文完全独立的上下文工具权限拥有所有工具可自定义限制生命周期整个会话完成任务后结束通信方式直接对话结果返回给主代理模型继承主会话设置可指定不同模型你可以创建专属子代理,指定模型、工具权限和系统提示。在对话中,Claude 会根据任务自动选择合适的子代理。

博客 5539

POJ-1207

The 3n + 1 problem Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 41880   Accepted: 13131 Description Problems in Computer Science are often classified as

x_liushi_game的专栏 576

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Inglish-Number Translator

题目描述In this problem, you will be given one or more integers in English. Your task is to translate these numbers into their integer representation. The numbers can range from negative 999,999,999 to po...

weixin_41514525的博客 759

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

What Kind of Friends Are You? ZOJ 3960

比赛的时候用vector交集做的。。。情况考虑的不全面 wrong到疯 赛后考虑全了情况。。。。T了 果然 set_intersection 不能相信 嗯 不好意思 交集a了 第二个代码 求出来每个1的交集 为0的时候 要减去相同的元素 看最后一个案例的B和K的输出想想为什么 另一个做法就是处理出每个人名的序列 然后输入序列的时候去找一样的 如果只有一个 那就...

babing2770的博客 203

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

POJ - 3468-A Simple Problem with Integers (树状数组)

You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the ...

creator平 315

What Kind of Friends Are You? ZOJ - 3960(ZheJiang Province Contest)

怎么说呢。。。我能说我又过了一道水题? emm。。。 问题描述: 给定 n 个待确定名字的Friends和 q 个问题。已知 c 个Friends的名字。 对于第 i 个问题,有个Friends会回答yes,其余个Friends均回答no。 现在给定 n 个待确定名字的Friends以及他们对于 q 个问题的回答。若能够确定它的名字,给出;否...

babing2770的博客 193

ZOJ 3960: What Kind of Friends Are You?

What Kind of Friends Are You?///@authorSycamore,ZJNU ///@date4/22/2017 #include<iostream> #include<sstream> #include<iomanip> #include<cmath> #include<string&g...

weixin_30332241的博客 151

ZOJ - 4102 Array in the Pocket

Array in the Pocket 部分公式复制不过来http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4102 Time Limit: 2 Seconds Memory Limit: 65536 KB BaoBao has just found an array of integers in his lef...

EIP_silly的博客 309

A DP Problem (字符串处理+模拟)

In this problem, you are to solve a very easy linear equation with only one variable x with no parentheses! An example of such equations is like the following: 2x - 4 + 5x + 300 = 98x An expressio

一只小菜鸡的博客 677

I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum o

#include #include using namespace std; int main(void) { string add(string str1, string str2); int n, i, j; cin>>n; string str1, str2, tstr1, tstr2; for(i = 1; i { cout cin>>str1>>str2; t

qq_37414992的博客 3227

UVa 486 - English-Number Translator

题目:给你一个数字的英文写法,翻译成阿拉伯数字(没有and)。 分析:模拟,递归。这个可以用很多方法求解吧。             这里利用递归,将数字分成几个部分的和(只考虑百万,千,万),分别求解相加即可。 说明:(⊙_⊙)。 #include #include #include #include #include #include using namespace st

小白菜又菜 3055

You are given a tetrahedron.

You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly. An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't st

fisty 1439

ZOJ3960-What Kind of Friends Are You?

What Kind of Friends Are You? Time Limit: 1 Second      Memory Limit: 65536 KB Japari Park is a large zoo home to extant species, endangered species, extinct species, cryptids and some legenda

wang_128的博客 546

ZOJ 3960 What Kind of Friends Are You?

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3960#include&lt;bits/stdc++.h&gt; using namespace std; int main(){ int t; cin&gt;&gt;t; while(t--) { int n,q; scanf("%d%d",&amp;n,&...

三水的鱼塘♂ 289
上一篇: 乱七八糟
下一篇: 蓝桥杯 带分数(DFS)
July_ing
博客等级 码龄11年 9粉丝 85原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值