16 多校 10 - K - Water problem (HDU - 5867 )

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

就是分类讨论一下然后打个表就好了。

#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int t,n,a[1010]={0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8};
int main()
{
    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[1000]=11;
    for(int i=21;i<1000;i++)
    {
        if(i<100)
            a[i] = a[(i/10)*10] + a[i%10];
        else
        {
            a[i] = a[i/100] + 7 + a[i%100];
            if(a[i%100])
                a[i] += 3;
        }
    }
    for(int i=1;i<=1000;i++)
        a[i] += a[i-1];
    cin>>t;
    while(t--)
    {
        cin>>n;
        cout<<a[n]<<endl;
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值