HDU 5867 Water problem 【】
来源:互联网 发布:超级淘宝系统下载 编辑:程序博客网 时间:2024/06/05 06:41
Water problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1051 Accepted Submission(s): 441
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
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<queue>#include<stack>#include<vector>#include<map>#include<set>#include<algorithm>using namespace std;#define ll long long#define ms(a,b) memset(a,b,sizeof(a))const int M=1e6+10;const int inf=0x3f3f3f3f;const int mod=1e9+7;int i,j,k,n,m;int a[100]={0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8,6};int main(){a[30]=6;a[40]=5;a[50]=5;a[60]=5;a[70]=7;a[80]=6;a[90]=6; int t; scanf("%d",&t); while(t--){ scanf("%d",&m); n=0; ll ans=0; for(int i=1;i<=m;i++){ n=i; if(n<=20)ans+=a[n]; else if(n<100){ int sum=0; sum+=a[(n/10)*10]; sum+=a[n%10]; ans+=sum; } else if(n%100==0&&n<1000){ ans+=7; ans+=a[n/100]; } else { if(n==1000){ans+=11;} else { int sum=0; sum+=a[n/100]; sum+=10; int kk=n-100*(n/100); if(kk<=20)sum+=a[kk]; else { int sum=0; sum+=a[(kk/10)*10]; sum+=a[kk%10]; ans+=sum; } ans+=sum; } } } printf("%lld\n",ans); } return 0;}
阅读全文
0 0
- hdu 5867 Water problem
- HDU 5867 Water problem
- HDU 5867 Water problem
- HDU 5867 Water problem
- HDU 5867 Water problem 【】
- hdu 5867 Water problem
- HDU-5867 Water problem(模拟)
- HDU 5867 Water problem (模拟)
- HDU 5867 Water problem(复杂水题)
- HDU 5867 Water problem(水~)
- HDU 5867Water problem 题如其名
- HDU 5867 Water problem——模拟
- 水题(Water problem,HDU 5867)
- Water problem HDU
- Water problem HDU
- Water problem HDU
- Water problem HDU
- hdu 5443 The Water Problem
- Lombok(1.14.8)的简单示例
- 浏览器文本显示自动替换单词间空格数量大于一的空格,替换为一个空格
- Java实现对称解密小程序用户信息(AES-128-CBC算法)
- destoon标签调用技巧
- jfreechart在linux下中文不显示或乱码的问题
- HDU 5867 Water problem 【】
- SCIM System for Cross-domain Identity Management (SCIM)
- Free DIY Tour HDU
- unable to open debugger port:java.net.SocketException以及直接运行报80端口被system占用
- iOS 计算富文本,检索网址,号码,表情,并且计算高度,设置最大行数
- spring中配置定时器
- vue-route+webpack单页路由项目,打包后访问正常刷新出现404问题
- poj 2585 Window Pains(拓扑排序)
- java代码关于自动发送邮箱