您的位置:首页 > 其它

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

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  模拟