水题(Water problem,HDU 5867)

通过数最多的题目,但是我却后面才做出来。

自己写代码确实有太多失误,到头来很难查错。

而且题目也确实是看错了,样例过不了,然后又理解错题意了。

其实根本就没有仔细看,第二句话我直接就无视了,只关注了题目大意。

感觉自己做题太浪了吧。。。

不靠谱的人什么事都做不好的。

不过本题主要也是因为在网上搜到了错误的拼写。

https://www.zybang.com/question/3d8e71404cb63fba3178cb955830bced.html

90应该是ninety而不是ninty,百度了一下发现ninty也是对的,只不过正规写法是ninety。

毕竟只有多校才会有这种题目。

比如什么原子第一电离能之类的。。。


代码

#include<stdio.h>
using namespace std;
const int maxn = 1010;
typedef long long ll;
const int And = 3;
const int hundred = 7;
const int thousand = 8;

int ge[21]={0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8,6};
int shi[11]={0,3,6,6,5,5,5,7,6,6,7};
ll ans[maxn];

int get(int x)
{
    if(x<=20) return ge[x];
    if(x<100) return shi[x/10]+ge[x%10];
    if(x<1000)
    {
        if(x%100==0) return ge[x/100]+hundred;
        else return ge[x/100]+hundred+And+get(x%100);
    }
    return ge[1]+thousand;
}

void init()
{
    for(int i=1;i<maxn;i++)
        ans[i]=ans[i-1]+get(i);
}

void solve()
{
    int N;
    scanf("%d",&N);
    printf("%lld\n",ans[N]);
}

void debug()
{
    int x;
    while(~scanf("%d",&x)) printf("%d\n",get(x));
}

int main()
{
    //debug();
    init();
    int T;
    scanf("%d",&T);
    while(T--) solve();
    return 0;
}


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值