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>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-8;
void File()
{
    freopen("D:\\in.txt","r",stdin);
    freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
    char c = getchar(); x = 0;while(!isdigit(c)) c = getchar();
    while(isdigit(c)) { x = x * 10 + c - ‘0‘; c = getchar();  }
}

int a[2000];
int b[15];

int main()
{
    b[1]=3; b[2]=3; b[3]=5; b[4]=4; b[5]=4;
    b[6]=3; b[7]=5; b[8]=5; b[9]=4;

    for(int i=1;i<=9;i++) a[i]=b[i];

    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; for(int i=21;i<=29;i++) a[i]=a[20]+b[i-20];
    a[30]=6; for(int i=31;i<=39;i++) a[i]=a[30]+b[i-30];
    a[40]=5; for(int i=41;i<=49;i++) a[i]=a[40]+b[i-40];
    a[50]=5; for(int i=51;i<=59;i++) a[i]=a[50]+b[i-50];
    a[60]=5; for(int i=61;i<=69;i++) a[i]=a[60]+b[i-60];
    a[70]=7; for(int i=71;i<=79;i++) a[i]=a[70]+b[i-70];
    a[80]=6; for(int i=81;i<=89;i++) a[i]=a[80]+b[i-80];
    a[90]=6; for(int i=91;i<=99;i++) a[i]=a[90]+b[i-90];

    int p;
    for(int i=100;i<=999;i++)
    {
        if(i%100==0)  p=i, a[i]=b[i/100]+7;
        else a[i]=a[p]+3+a[i-p];
    }
    a[1000]=11;

    for(int i=2;i<=1000;i++) a[i]=a[i]+a[i-1];

    int T; scanf("%d",&T);
    while(T--)
    {
        int n; scanf("%d",&n);
        printf("%d\n",a[n]);
    }
    return 0;
}
时间: 2024-11-05 21:51:32

HDU 5867 Water problem的相关文章

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> #incl

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 5832A water problem

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

hdu 4974 A simple water problem(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4974 Problem Description Dragon is watching competitions on TV. Every competition is held between two competitors, and surely Dragon's favorite. After each competition he will give a score of either 0 or

HDU 4974 A simple water problem(贪心)

HDU 4974 A simple water problem 题目链接 签到题,很容易贪心得到答案是(sum + 1) / 2和ai最大值的最大值 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N = 100005; typedef long long ll; int t, n; ll a, Max, sum; int main(

HDU - 4974 A simple water problem

Problem Description Dragon is watching competitions on TV. Every competition is held between two competitors, and surely Dragon's favorite. After each competition he will give a score of either 0 or 1 for each competitor and add it to the total score

2014多校第十场1004 || HDU 4974 A simple water problem

题目链接 题意 : n支队伍,每场两个队伍表演,有可能两个队伍都得一分,也可能其中一个队伍一分,也可能都是0分,每个队伍将参加的场次得到的分数加起来,给你每个队伍最终得分,让你计算至少表演了几场. 思路 : ans = max(maxx,(sum+1)/2) :其实想想就可以,如果所有得分中最大值没有和的一半大,那就是队伍中一半一半对打,否则的话最大的那个就都包了. 1 #include <cstdio> 2 #include <cstring> 3 #include <st

HDU 5832 A water problem(某水题)

HDU 5832 A water problem(某水题) Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)   Problem Description - 题目描述 Two planets named Haha and Xixi in the universe and they were created with the universe beginning. There is

(线段树 区间查询)The Water Problem -- hdu -- 5443 (2015 ACM/ICPC Asia Regional Changchun Online)

链接: http://acm.hdu.edu.cn/showproblem.php?pid=5443 The Water Problem Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 738    Accepted Submission(s): 591 Problem Description In Land waterless, w