2016多校训练Contest10: 1011 Water problem hdu5867
2016-08-18 23:07
369 查看
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.
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.
Output
For each case, print the number of letters would be used.
Sample Input
Sample Output
队友直接打了个大表。。服气。。
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.
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.
Output
For each case, print the number of letters would be used.
Sample Input
3 1 2 3
Sample Output
3 6 11
队友直接打了个大表。。服气。。
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <algorithm> #include <string.h> #include <iostream> #include <set> #include <map> #include <vector> #include <queue> #include <stack> using namespace std; const int INF = 2147483647; const double PI = acos(-1); /* ----------------- code ----------------- */ int a[1001]={0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8,6,9,9,11,10,10,9,11,11,10,6,9,9,11,10,10,9,11,11,10,5,8,8,10,9,9,8,10,10,9,5,8,8,10,9,9,8,10,10,9,5,8,8,10,9,9,8,10,10,9,7,10,10,12,11,11,10,12,12,11,6,9,9,11,10,10,9,11,11,10,6,9,9,11,10,10,9,11,11,10,10,16,16,18,17,17,16,18,18,17,16,19,19,21,21,20,20,22,21,21,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,18,21,21,23,22,22,21,23,23,22,18,21,21,23,22,22,21,23,23,22,18,21,21,23,22,22,21,23,23,22,20,23,23,25,24,24,23,25,25,24,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,10,16,16,18,17,17,16,18,18,17,16,19,19,21,21,20,20,22,21,21,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,18,21,21,23,22,22,21,23,23,22,18,21,21,23,22,22,21,23,23,22,18,21,21,23,22,22,21,23,23,22,20,23,23,25,24,24,23,25,25,24,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,12,18,18,20,19,19,18,20,20,19,18,21,21,23,23,22,22,24,23,23,21,24,24,26,25,25,24,26,26,25,21,24,24,26,25,25,24,26,26,25,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,22,25,25,27,26,26,25,27,27,26,21,24,24,26,25,25,24,26,26,25,21,24,24,26,25,25,24,26,26,25,11,17,17,19,18,18,17,19,19,18,17,20,20,22,22,21,21,23,22,22,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,21,24,24,26,25,25,24,26,26,25,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,11,17,17,19,18,18,17,19,19,18,17,20,20,22,22,21,21,23,22,22,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,21,24,24,26,25,25,24,26,26,25,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,10,16,16,18,17,17,16,18,18,17,16,19,19,21,21,20,20,22,21,21,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,18,21,21,23,22,22,21,23,23,22,18,21,21,23,22,22,21,23,23,22,18,21,21,23,22,22,21,23,23,22,20,23,23,25,24,24,23,25,25,24,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,12,18,18,20,19,19,18,20,20,19,18,21,21,23,23,22,22,24,23,23,21,24,24,26,25,25,24,26,26,25,21,24,24,26,25,25,24,26,26,25,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,22,25,25,27,26,26,25,27,27,26,21,24,24,26,25,25,24,26,26,25,21,24,24,26,25,25,24,26,26,25,12,18,18,20,19,19,18,20,20,19,18,21,21,23,23,22,22,24,23,23,21,24,24,26,25,25,24,26,26,25,21,24,24,26,25,25,24,26,26,25,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,22,25,25,27,26,26,25,27,27,26,21,24,24,26,25,25,24,26,26,25,21,24,24,26,25,25,24,26,26,25,11,17,17,19,18,18,17,19,19,18,17,20,20,22,22,21,21,23,22,22,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,19,22,22,24,23,23,22,24,24,23,21,24,24,26,25,25,24,26,26,25,20,23,23,25,24,24,23,25,25,24,20,23,23,25,24,24,23,25,25,24,11}; int main(void){ int t; scanf("%d",&t); while(t--){ int n; scanf("%d",&n); int ans = 0; for(int i=1;i<=n;i++){ ans += a[i]; } printf("%d\n",ans); } return 0; }
相关文章推荐
- 2016多校训练Contest8: 1011 Rikka with Parenthesis II hdu5831
- 2016 Multi-University Training Contest 8(2016多校训练第八场)1011
- 2016多校训练Contest10: 1002 Hard problem hdu5858
- 2016第三场多校联盟训练1011 Teacher Bo(曼哈顿距离)
- 2016多校训练Contest10: 1006 Counting Intersections hdu5862
- 2016多校训练Contest10: 1003 Captain is coding hdu5859
- HDU 5867 Water problem (2016 多校训练#10 1011)
- 2016第三场多校联盟训练1011
- 2016 Multi-University Training Contest 4(2016多校训练第四场)1011
- 2016多校训练Contest10: 1007 cjj's string game hdu5863
- #2016多校训练Contest10: 1011 Water problem hdu5867
- 2016多校训练Contest5: 1011 Two hdu5791
- 2016多校训练Contest10: 1001 Median hdu5857
- hdu 5803 Zhu’s Math Problem (2016多校第六场1011)数位dp
- 2016 Multi-University Training Contest 2(2016多校训练第二场)1009
- HDOJ 5738 (2016多校联合训练 Training Contest 2) Eureka
- 2016多校训练Contest4: 1006 Substring hdu5769
- 2016多校训练Contest6: 1007 This world need more Zhu hdu5799
- [HDU5826] physics [2016 Multi-University Training Contest 8(2016多校联合训练8) 1006]
- HDOJ 5734 (2016多校联合训练 Training Contest 2) Acperience