SDNU Warming up for Team Selection

HDU 3343 
Long long ago, there is an ant crawling on an L-meter magic rubber band with speed of v cm/s.The magic rubber band will elongate m meters every second. We can assume that the magic rubber band elongates equably. Now, the ant is on the start point and crawling to another point, please tell me whether it can reach the endpoint.
InputThe first line of the input is T, which stands for the number of test cases you need to solve. 
Each case include three integers: L , v , m ( 0< L< 10^9,0<= v, m< 10^ 9,).OutputFor each test case, if the ant can reach endpoint, output "YES", otherwise "NO".Sample Input
1
99999 61 1
Sample Output
YE

哇 ,做这道题刚开始竟然以为拉长是向一边拉的,就去列了个到终点的方程式。(sibusisa)

结果可想而知,据搜到的题解:设蚂蚁左方l1,右方l2,L = l1 + l2 , k = l1/L;

如果蚂蚁不动,杆伸长,K不变,所以蚂蚁向右移动的时候,蚂蚁速度恒定,k就一直增大,越来越趋近于1

所以当V>0 时即可。

HDU  3345

war  chess

比赛时就在做这道题,考虑不到位,然后还输不出。   绕啊绕啊绕,绕晕了自己。

本来想着所有的点都初始化为0,然后初始的MV记作刚开始的T,遍历一个点就减去这个点的MV值,直到减为0,结果最后要输出时未遍历的和MV等于0的分不开,所以初始化要都设成-1,还有这样也不好记录所到点剩余MV的数量哪个更多点,所以还是初始化时起点的MV为0比较好,经过一个点将MV数量增加,每次选择路途中少的入队,最后判断就行。

这道题后来自己写得太凌乱了,写不成个样子了,搜了篇不错的博客,比较清晰,(我就照猫画虎画了一画)要注意得地方还是很多啊。

所以思路:bfs 遍历四周,另设数组f【maxn】【maxn】标记每次所到点用去了多少MV,只要这个点所用MV更少,就可以入队,具体分的那么几种情况中需要特别注意“#”,走到这MV值标记为0,还有“E”,只要非起点的周边有E,就不入队了,如果起点周围有E,让其他非“E”点入队。最后输出。

/*******还是看代码吧,剪不断,理还乱********/

#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
const int maxn = 105;
using namespace std;
int a[maxn][maxn];
char b[maxn][maxn];
int f[maxn][maxn];
int  n,m;
int c[4] = {0,0,-1,1};
int d[4] = {1,-1,0,0};
bool  check(int l,int p)
{
    for(int i = 0 ; i < 4; i++)
    {
        if(a[l+c[i]][p+d[i]]==-1)
            return false;
    }
    return true;
}
int main()
{
    int t;
    int T;
    cin>>T;
    int x,y;
    while(T--)
    {
        cin>>n>>m;
        cin>>t;
        memset(a,0,sizeof(a));
memset(f,-1,sizeof(f));


        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j< m; j++)
            {
                cin>>b[i][j];
                if(b[i][j]=='Y')
                {
                    a[i][j] = 1;
                    x = i;
                    y = j;




                }
                if(b[i][j]=='P')
                {
                    a[i][j] = 1;
                }
                if(b[i][j]=='.')
                {
                    a[i][j] = 1;
                }
                if(b[i][j]=='T')
                {
                    a[i][j] = 2;
                }
                if(b[i][j]=='R')
                {
                    a[i][j] = 3;
                }
                if(b[i][j]=='E')
                {
                    a[i][j] = -1;
                }
                if(b[i][j] =='#')
                {
                    a[i][j] = 0;
                }
            }


        }
        queue<  pair<int,int>  >que;
        que.push(make_pair(x,y));
       f[x][y] = 0;
        while(!que.empty())
        {
            pair<int,int> pp = que.front();
            que.pop();
            if(!check(pp.first,pp.second)&&pp!=make_pair(x,y))
                continue;
            for(int i = 0; i< 4; i++)
            {
                int dx = pp.first + c[i];
                int dy = pp.second + d[i];
                if(a[dx][dy]<=0)
                    continue;
                if(f[dx][dy] == -1 ||f[dx][dy]>f[pp.first][pp.second] + a[dx][dy])
                {
                    f[dx][dy] = f[pp.first][pp.second] + a[dx][dy];
                    que.push(make_pair(dx,dy));
                }
            }


        }
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j< m; j++)
            {
                if(f[i][j]>0&&f[i][j]<=t&&b[i][j]!='P'&&a[i][j]>0)
                {
                    printf("*");
                }
                else
                    printf("%c",b[i][j]);
            }
            putchar('\n');
    }
    putchar(10);
}
}

HDU, 3346 

 整除8,各位数和整除8,各位数的平方和整除8


HDU  3347

看起来好简单呐,map 一一对应,当作字符串分情况处理

wa过的一次是因为没有考虑 这种 1 - -1 = 2

所以还是要注意啊。


HDU  3349

这个题我觉得就是数学问题

分三种情况来考虑,需要擦掉的面积是三角形时,

                             是正方形减三角形面积时

                             就是正方形时

判断条件:拿正方形对角线与矩形短边的一半做比较,因为要保证最小只要满足正方形对角线中心即可。

HDU 3348

coins 这个题最小的用贪心,大的优先,如果用最少的纸张都无法换,也就没最大的纸张值。

所以在求最大张数时 只要换另一种方向,就是这种形式:

while(a[0]+a[1]*5+a[2]*10+a[3]*50 < pp)  
                {
                    pp -=100;
                    sum3++;
                }



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值