偶尔写写ACM水题还是挺好玩的。(好吧其实是老婆求助我才看滴)

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

一开始看到这题的时候,感觉一天24小时60分钟60秒。把每一秒的最小指针角度记下来再搞个排序。

每个case二分搜一下就好啦。

结果发现最后一个case的结果始终是错的。

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

题目要我们计算1,0的排列方式总数,并且对任意长的字符串,1的数量大于等于0的数量

我们可以把题目转化为从(0,0)点到(m,n)点的方法总数,且路径不经过y=x-1这条直线

然后我们可以把从(-1,-1)到(m,n)的所有路径按以y=x-1翻转,所得到的路径显然就是经过y=x-1的所有方案

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

这题就是一道简单的两重三分

首先设e点为从ab上离开的点,f为从cd上进入的点

显然对固定点e,f从距c的距离的长度是一个单调函数或者先减后增的函数,这里可以三分算出最优解。这里是第一个三分

然后对e点的最优解易证也存在这个性质,所以再来一个三分,就能解除最优解

题目: http://acm.hdu.edu.cn/showproblem.php?pid=3336

水题一道,主要是测试数据很水

不解释,贴代码:

#include 
#include 
#include 
#include 
using namespace std;

char str[200005];
vectorglo_Pos;
int main()
{
    int t;
    long output,i,n,j;
    scanf("%d",&t);
    while(t --)
    {
        output = 0;
        glo_Pos.clear();
        scanf("%ld %s", &n, str);

        for(i = 0; i < n; i ++)
        {
            if(str[i] == str[0])
            {
                glo_Pos.push_back(i);
                output ++;
            }
        }
        output = output % 10007;
        for(i = 1; i < n; i ++)
        {
            for(j = 0; j < glo_Pos.size();j ++)
            {
                if(str[i] == str[glo_Pos[j] + i])
                    output = (output + 1) % 10007;
                else
                {
                    glo_Pos.erase(glo_Pos.begin() + j);
                    j --;
                }
            }
        }

        printf("%ld\n", output);
    }
    return 0;
}