HDU5867-Water problem
来源:互联网 发布:开发一个刷赞软件 编辑:程序博客网 时间:2024/06/08 13:19
Water problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1144 Accepted Submission(s): 476
Problem Description
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3+3+5+4+4=19 letters used in total.If all the numbers from 1 to n (up to one thousand) inclusive were written out in words, how many letters would be used?
Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of "and" when writing out numbers is in compliance with British usage.
Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of "and" when writing out numbers is in compliance with British usage.
Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases.
For each test case: There is one positive integer not greater one thousand.
For each test case: There is one positive integer not greater one thousand.
Output
For each case, print the number of letters would be used.
Sample Input
3123
Sample Output
3611
Author
BUPT
Source
2016 Multi-University Training Contest 10
Recommend
wange2014
题意:问[1,n]这些数字用英文单词表示的时候一共用了多少个字母
解题思路:暴力模拟
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <map>#include <cmath>#include <set>#include <stack>#include <queue>#include <vector>#include <bitset>#include <functional>using namespace std;#define LL long longconst int INF = 0x3f3f3f3f;int a[1005];int sum[1005];int main(){a[1] = 3;a[2] = 3;a[3] = 5;a[4] = 4;a[5] = 4;a[6] = 3;a[7] = 5;a[8] = 5;a[9] = 4;a[10] = 3;a[11] = 6;a[12] = 6;a[13] = 8;a[14] = 8;a[15] = 7;a[16] = 7;a[17] = 9;a[18] = 8;a[19] = 8;a[20] = 6;a[30] = 6;a[40] = 5;a[50] = 5;a[60] = 5;a[70] = 7;a[80] = 6;a[90] = 6;a[1001] = 7;//baia[1002] = 8;//qiana[1003] = 3;//and;for (int i = 21; i<100; i++){if (i % 10 == 0) continue;a[i] = a[i / 10 * 10] + a[i % 10];}for (int i = 100; i<1000; i++){if (i % 100 == 0) a[i] = a[i / 100] + a[1001];else a[i] = a[i / 100] + a[1001] + a[1003] + a[i % 100];}a[1000] = a[1] + a[1002];sum[0] = 0;for (int i = 1; i <= 1000; i++) sum[i] = sum[i - 1] + a[i];int t, n;scanf("%d", &t);while(t--){scanf("%d", &n);printf("%d\n", sum[n]);}return 0;}
阅读全文
0 0
- 【HDU5867】Water problem(模拟)
- HDU5867 Water problem
- HDU5867-Water problem
- 2016多校训练Contest10: 1011 Water problem hdu5867
- #2016多校训练Contest10: 1011 Water problem hdu5867
- Water problem
- A simple water problem
- 1810: water problem II
- A water problem
- Water and Jug Problem
- A water problem
- hdu5832 A water problem
- A water problem
- A water problem
- A water problem
- hdu 5867 Water problem
- HDU 5867 Water problem
- HDU 5867 Water problem
- java 把byte转化为KB、MB、GB的方法
- USB 3G上网卡讲解之一
- 谈MVVM
- 最大子串和
- 约束布局constraint-layout导入失败的解决方案
- HDU5867-Water problem
- pgsql 计算时间差的秒数
- Leetcode OJ 24 Swap Nodes in Pairs [Medium]
- Unity3D 关于模型变形技术代码实现
- Swift 中的方法(函数)
- python-7
- Ruby:字符串处理函数
- 新版Bintray-极简上传Library到JCenter
- 删除文本中行尾空格-linux