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]);
    }
}

时间: 2024-10-13 01:48:27

HDU 5867 Water problem (2016 多校训练#10 1011)的相关文章

HDU 5858 Hard problem (2016 多校训练#10 1002)

题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5858 题意:给出下图和正方形边长,求阴影部分面积. 分析:数学题,总之就是割来割去推公式,比赛时是队友打的,拿他代码直接贴了. 具体分析可以看这里. http://www.zybang.com/question/1301cb472211299680f8d4796e7dc797.html 代码: #include<cstdio> #include<cmath> #includ

HDU 5867 Water problem ——(模拟,水题)

我发这题只是想说明:有时候确实需要用水题来找找自信的~ 代码如下: 1 #include <stdio.h> 2 #include <algorithm> 3 #include <string.h> 4 using namespace std; 5 typedef long long ll; 6 7 int num[1000+5] = {0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8,6}; 8 int sum[1000+5]; 9 10

HDU 5867 Water problem

处理出1-99的,之后的加上多少hundred和and即可.整百和一千的时候注意一下. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #includ

HDU 4920(杭电多校训练#5 1010 题) Matrix multiplication(不知道该挂个什么帽子。。。)

题目地址:HDU 4920 对这个题简直无语到极点...居然O(n^3)的复杂度能过....方法有三.. 1:进行输入优化和输出优化..(前提是你的输入优化不能太搓...) 2:利用缓存优化..详情请看该论文.大体就是将后两个for循环换过来,让坐标改变的频率降下来. 3:叉姐题解中说的正规方法..利用biset存储,进行预处理..(其实我还没看懂.. 我只写了个第二种...代码如下,共勉..神奇的小代码.. #include <iostream> #include <cstdio>

HDU5753 Permutation Bo(2016多校训练)

Permutation Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 777    Accepted Submission(s): 468Special Judge Problem Description There are two sequences h1∼hn and c1∼cn . h1∼hn is a permutat

HDU 4869 Turn the pokers 多校训练第一场1009

Turn the pokers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 282    Accepted Submission(s): 89 Problem Description During summer vacation,Alice stay at home for a long time, with nothing to

HDU5752 Sqrt Bo(2016多校训练)

Sqrt Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1173    Accepted Submission(s): 528 Problem Description Let's define the function f(n)=⌊n−−√⌋ . Bo wanted to know the minimum number y w

hdu 5734 Acperience(2016多校第二场)

Acperience Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 484    Accepted Submission(s): 258 Problem Description Deep neural networks (DNN) have shown significant improvements in several applic

HDU 5832A water problem

大数 判断整除 /* *********************************************** Author :guanjun Created Time :2016/8/14 19:04:01 File Name :hdu5832.cpp ************************************************ */ #include <iostream> #include <cstring> #include <cstdlib&