水题大作战-updated continuously

这些水题是在无聊的时候刷刷,提高编码速度和编码准确度的,同时也是为了保持状态,有同样需求的同学可以看看题目列表刷一刷。另外竞赛的初学者也可以用这些题目练练手,提高自信……该篇博文将会持续更新。


HDU 1036

根据题意计算结果,注意四舍五入就可以了。


HDU 4452

这道题就是纯模拟,细节处理的时候小心一点就行了。题意是说在左上角有兔子tom,右下角有兔子jerry,然后按照下面的规则进行跑动。

* 每只兔子在单位时间内走动一定的格子数

* 如果遇到墙壁,则反向继续运动

* 如果两只兔子相遇,则各自的运动方向互换

* 每只兔子间隔t的时间左转一次,如果两只兔子相遇则忽略转向

还是贴一段代码上来供需要的同学参考一下:

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;

const int dir[4][2] = {{1, 0},{0, 1}, {-1, 0}, {0, -1}};

int N;

typedef struct NODE
{
	int x, y;
	int direction;
	int speed;
	int t;
}Node;

Node tom, jerry;

void runOneTime(Node &node)
{
	if(node.direction == 0)
	{
		int temp = node.x+node.speed;
		if(temp > N)
		{
			temp -= N;
			node.x = N-temp;
			node.direction = (node.direction+2)%4;
		}
		else
			node.x = temp;
	}
	else if(node.direction == 2)
	{
		int temp = node.x-1;
		if(temp < node.speed)
		{
			node.x = 1+(node.speed-temp);
			node.direction = (node.direction+2)%4;
		}
		else
			node.x -= node.speed;
	}
	else if(node.direction == 1)
	{
		int temp = N-node.y;
		if(temp < node.speed)
		{
			node.y = N-(node.speed-temp);
			node.direction = (node.direction+2)%4;
		}
		else
			node.y += node.speed;
	}
	else if(node.direction == 3)
	{
		int temp = node.y-1;
		if(temp < node.speed)
		{
			node.y = 1+(node.speed-temp);
			node.direction = (node.direction+2)%4;
		}
		else
			node.y -= node.speed;
	}
}

int getDirection(char *s)
{
	if(s[0] == 'S')
		return 0;
	else if(s[0] == 'E')
		return 1;
	else if(s[0] == 'N')
		return 2;
	else if(s[0] == 'W')
		return 3;
}

void swap(int &a, int &b)
{
	int temp = a;
	a = b;
	b = temp;
}

void solve(int K)
{
	for(int i=1; i<=K; i++)
	{
		runOneTime(tom);
		runOneTime(jerry);
		if(tom.x == jerry.x && tom.y == jerry.y)
		{
			swap(tom.direction, jerry.direction);
		}
		else
		{
			if(i%tom.t == 0)
				tom.direction = (tom.direction + 1)%4;
			if(i%jerry.t == 0)
				jerry.direction = (jerry.direction + 1)%4;
		}
	}
	printf("%d %d\n", tom.x, tom.y);
	printf("%d %d\n", jerry.x, jerry.y);
}

int main()
{
	char sdirection[10];
	int speed;
	int t;
	while(scanf("%d", &N) && N)
	{
		scanf("%s%d%d", sdirection, &speed, &t);
		tom.x = 1;
		tom.y = 1;
		tom.direction = getDirection(sdirection);
		tom.speed = speed;
		tom.t = t;
		
		scanf("%s%d%d", sdirection, &speed, &t);
		jerry.x = N;
		jerry.y = N;
		jerry.direction = getDirection(sdirection);
		jerry.speed = speed;
		jerry.t = t;

		int K;
		scanf("%d", &K);
		solve(K);
	}
	return 0;
}

HDU 1033

这道题的英文体面很坑爹,其实的意思就是说从其点(310, 420),按照每次走10的距离行走,给定的串表示在当前点的方向的改变,A表示顺时针,V表示逆时针。程序要求然后按照题意模拟,输出每次达到的点。。。

what a fucking English translated by some German college students.....


HDU 4730

题意很简单,就是当一个串以desu结尾时,将串尾的desu替换成nanodesu;否则就在整个串的末尾填上nanodesu。大水题。。。


HDU 1302

这道题大概是说蜗牛从井底向上爬,白天向上爬一段距离,然后晚上滑下一定的距离,问经过多少天会爬出井外或者是掉回井底。注意这里的爬出井外是指爬行的当前高度大于井深才算successful,而掉下井底的条件为高度小于0才failed,注意到这两点就行了。

题目给的值很小,按照题意对每天进行模拟就行了。


HDU 1861

题中的船编号很小,直接记录船的借出时间,同时根据题意忽略掉不合法的租借记录就行了。

点击关注我的新浪微博:Sina weibo

欢迎扫描关注微信公众账号:CodingRush,将不定时为您推送算法、编程等IT知识和人生感悟相关文章。

     


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值