Content

请输出整数 \(s\) 的英文写法。

数据范围:\(0\leqslant s\leqslant 99\)。

Solution

直接对应打表即可。

  • 当 \(0\leqslant s\leqslant 19\),直接特判对应输出即可。
  • 当 \(20\leqslant s\leqslant 99\),碰到整十数就先输出对应的英文单词,如果后面还有数,先加上一个连字符,再输出个位上的数字。

建议做完这题目之后再去做做 P1617

Code

const string num[11] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
const string ty[11] = {"", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};
const string teen[21] = {"", "", "", "", "", "", "", "", "", "", "", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
int a[5], n, cnt; int main() {
scanf("%d", &n);
int tmp = n;
while(tmp) {
a[++cnt] = tmp % 10;
tmp /= 10;
}
int teens = a[2] * 10 + a[1];
if(cnt == 2) {
if(teens >= 11 && teens <= 19)
cout << teen[teens];
else if(!a[1]) {
if(a[2] == 1) cout << ty[1];
else cout << ty[a[2]];
}
else
cout << ty[a[2]] << '-' << num[a[1]];
} else
cout << num[a[1]];
return 0;
}

CF535A Tavas and Nafas 题解的更多相关文章

  1. Codeforces Round #299 (Div. 2) A. Tavas and Nafas 水题

    A. Tavas and Nafas Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/pr ...

  2. CF Tavas and Nafas

     Tavas and Nafas time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  3. 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas

    题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...

  4. 【Codeforces Round #299 (Div. 2) A】 Tavas and Nafas

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟题 [代码] #include <bits/stdc++.h> using namespace std; map & ...

  5. [CF535D]Tavas and Malekas 题解

    题意简述 有一个空着的长度为\(n\)的字符串\(ans\),再给出一个长度为\(m\)的序列\(a\),现要在序列中每个元素\(a_i\)的位置开始都规定必须为一个给定的字符串\(s\).问字符串\ ...

  6. Codeforces Round #299 (Div. 2)A B C 水 dfs 二分

    A. Tavas and Nafas time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  7. Codeforces Round #299 Div2 解题报告

    这场比赛并没有打现场,昨天晚上做了ABCD四道题,今天做掉了E题 以前还没有过切完一场比赛的所有题呢~爽~ A. Tavas and Nafas   Today Tavas got his test ...

  8. CF Tavas and Karafs (二分)

    Tavas and Karafs time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  9. Codeforces Round #299 (Div. 2) D. Tavas and Malekas kmp

    题目链接: http://codeforces.com/problemset/problem/535/D D. Tavas and Malekas time limit per test2 secon ...

随机推荐

  1. 初识XSS攻击

    初识XSS攻击 本文参考于<白帽子讲Web安全>第3章跨站脚本攻击(XSS),该书出版于2014年,因而现在可能存在一些新场景或新技术而未被提及,但本文对学习和了解XSS攻击仍具有重要价值 ...

  2. SpringCloud升级之路2020.0.x版-43.为何 SpringCloudGateway 中会有链路信息丢失

    本系列代码地址:https://github.com/JoJoTec/spring-cloud-parent 在开始编写我们自己的日志 Filter 之前,还有一个问题我想在这里和大家分享,即在 Sp ...

  3. 联盛德 HLK-W806 (一): Ubuntu20.04下的开发环境配置, 编译和烧录说明

    目录 联盛德 HLK-W806 (一): Ubuntu20.04下的开发环境配置, 编译和烧录说明 联盛德 HLK-W806 (二): Win10下的开发环境配置, 编译和烧录说明 联盛德 HLK-W ...

  4. JOI 2020 Final 题解

    T1. 只不过是长的领带 大水题,把 \(a_i,b_i\) 从小到大排序. 发现最优方案只可能是大的 \(a_i\) 跟大的 \(b_i\) 匹配,小的 \(a_i\) 与小的 \(b_i\) 匹配 ...

  5. Cycling City CF521E

    Cycling City 毒瘤题 首先建dfs树,由于是个无向图所有返祖边都是连向祖先的. 判是否有解其实很简单,只要图不是一个仙人掌就有解了. 仙人掌有关可以看这个博客 但是这道题由于要输出路径成功 ...

  6. 【机器学习与R语言】10- 关联规则

    目录 1.理解关联规则 1)基本认识 2)Apriori算法 2.关联规则应用示例 1)收集数据 2)探索和准备数据 3)训练模型 4)评估性能 5)提高模型性能 1.理解关联规则 1)基本认识 购物 ...

  7. python16线程

    python对于I/O密集型应用比较好,具体根据是什么类型应用来查看 对于cpu密集型应用可以借助python的一些扩展去实现 thread模块是比较早期的模块,thresding是比较新的模块,对t ...

  8. you crash I crash

    今天一大早起来,zabbix报错了 我去查看了mysql的状态 MySQL is not running, but lock file (/var/lock/subsys/mysql) exists ...

  9. Python基础之字典内置方法

    目录 1. 字典 1.1 字典的作用 1.2 创建和使用字典 1.2.1 dict类 1.2.2 基本的字典操作 1.2.3 字典方法 1. 字典 映射:可以通过名称来访问其各个值的数据结构. 字典是 ...

  10. Telink BLE MESH PWM波的小结

    本本针对Telink BLE MESH SDK  灯控的使用进行说明. 1.调整灯光的频率 默认情况下 SDK PWM波的频率是 600HZ的,有时我们需要将它调整频率,例如调整为4K,只需要更改参数 ...