HDU 5867 Water problem (2016 多校训练#10 1011)

题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5867

题意:给一个不超过一千的数字N,求出1-N所有单词加起来的字母个数和(f(1)=len(one)=3,f(2)=f(1)+len(two)=6...)。

分析:一看名字就知道是到水题了...直接打表。(保险起见,我还手打了20内的表)。

 

代码:

#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdlib>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
#define Max(a,b) (a>b)?a:b
#define lowbit(x) x&(-x)

int main()
{
    int a[1005]={0};
    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[100]=3+7;

    for(int i=20;i<100;i+=10)
    {
        for(int j=i+1;j<i+10;j++)
            a[j]=a[i]+a[j-i];
    }
    for(int i=100;i<1000;i+=100)
    {
        a[i]=a[i/100]+7;
        for(int j=i+1;j<=i+99;j++)
        {
            a[j]=a[i]+3+a[j-i];
        }
    }
    a[1000]=3+8;
    for(int i=2;i<=1000;i++)
        a[i]+=a[i-1];
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        printf("%d\n",a[n]);
    }
}
View Code

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值