通过数最多的题目,但是我却后面才做出来。
自己写代码确实有太多失误,到头来很难查错。
而且题目也确实是看错了,样例过不了,然后又理解错题意了。
其实根本就没有仔细看,第二句话我直接就无视了,只关注了题目大意。
感觉自己做题太浪了吧。。。
不靠谱的人什么事都做不好的。
不过本题主要也是因为在网上搜到了错误的拼写。
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;
}