HDU 4445 Running Rabbits(模拟)

icem二维非结构网格划分_ICEM CFD网格装配 正文共:718字7图 预计阅读时间:2分钟1 前言 对于一些大型的复杂的网格划分,可以将整个模型切分成多个子模型(二维几何用线切分,三维模型用面切分),然后对各个模型单独划分网格,最终装配在一起。这和机械设计的零件设计和装配设计有点相似,这个功... 阅读详情

Running Rabbits

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1792    Accepted Submission(s): 1257


Problem Description
Rabbit Tom and rabbit Jerry are running in a field. The field is an N×N grid. Tom starts from the up-left cell and Jerry starts from the down-right cell. The coordinate of the up-left cell is (1,1) and the coordinate of the down-right cell is (N,N)。A 4×4 field and some coordinates of its cells are shown below:

The rabbits can run in four directions (north, south, west and east) and they run at certain speed measured by cells per hour. The rabbits can't get outside of the field. If a rabbit can't run ahead any more, it will turn around and keep running. For example, in a 5×5 grid, if a rabbit is heading west with a speed of 3 cells per hour, and it is in the (3, 2) cell now, then one hour later it will get to cell (3,3) and keep heading east. For example again, if a rabbit is in the (1,3) cell and it is heading north by speed 2,then a hour latter it will get to (3,3). The rabbits start running at 0 o'clock. If two rabbits meet in the same cell at k o'clock sharp( k can be any positive integer ), Tom will change his direction into Jerry's direction, and Jerry also will change his direction into Tom's original direction. This direction changing is before the judging of whether they should turn around.
The rabbits will turn left every certain hours. For example, if Tom turns left every 2 hours, then he will turn left at 2 o'clock , 4 o'clock, 6 o'clock..etc. But if a rabbit is just about to turn left when two rabbit meet, he will forget to turn this time. Given the initial speed and directions of the two rabbits, you should figure out where are they after some time.
 

Input
There are several test cases.
For each test case:
The first line is an integer N, meaning that the field is an N×N grid( 2≤N≤20).
The second line describes the situation of Tom. It is in format "c s t"。c is a letter indicating the initial running direction of Tom, and it can be 'W','E','N' or 'S' standing for west, east, north or south. s is Tom's speed( 1≤s<N). t means that Tom should turn left every t hours( 1≤ t ≤1000).
The third line is about Jerry and it's in the same format as the second line.
The last line is an integer K meaning that you should calculate the position of Tom and Jerry at K o'clock( 1 ≤ K ≤ 200).
The input ends with N = 0.
 

Output
For each test case, print Tom's position at K o'clock in a line, and then print Jerry's position in another line. The position is described by cell coordinate.
 

Sample Input
  
4 E 1 1 W 1 1 2 4 E 1 1 W 2 1 5 4 E 2 2 W 3 1 5 0
 

Sample Output
  
2 2 3 3 2 1 2 4 3 1 4 1
 

Source
2012 Asia JinHua Regional Contest


题意:这题题目一定得好好读,因为有很多细节,如果全部读懂了就很简单了,就是一道普通的模拟。有两只兔子,Tom跟Jerry给定他们的初始位置、初始方向、转向的周期,比如周期为二那么在2、4、6时刻兔子就会向当前方向的左侧转,如果兔子到达边界时就会反向,如果两只兔子在k时刻相遇(在k-1到k期间相遇不算)那么兔子相互交换
方向。但是有个优先级关系,如果在k时刻两只兔子相遇也需要转向,那么他只要交换方向就可以,然后再判断是否到达边界。

解题思路:就是一个模拟题,把思路理清就好,详细见代码。

<span style="font-size:18px;">#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
struct node{
   char c;
   int v,time,x,y;
}tom,jer;
int n,k;
void walk(node & a)
{
    if(a.c=='N'){
        if(a.v<=a.y-1) a.y=a.y-a.v;
        else{
            a.c='S';
            a.y=1+(a.v-(a.y-1));
        }
    }
    else if(a.c=='S'){
        if(a.v<=n-a.y) a.y+=a.v;
        else{
            a.c='N';
            a.y=n-(a.v-(n-a.y));
        }
    }
    else if(a.c=='W')
    {
        if(a.v<=a.x-1) a.x-=a.v;
        else{
            a.c='E';
            a.x=1+(a.v-(a.x-1));
        }
    }
    else{
        if(a.v<=n-a.x) a.x+=a.v;
        else{
            a.c='W';
            a.x=n-(a.v-(n-a.x));
        }
    }
}
bool panduan(node a,node b)
{
    if(a.x==b.x && a.y==b.y) return true;
    else return false;
}
void change(node &a)
{
    if(a.c=='E') a.c='N';
    else if(a.c=='S') a.c='E';
    else if(a.c=='W') a.c='S';
    else if(a.c=='N') a.c='W';
}
int main(){
    while(~scanf("%d",&n) &&n)
    {
        getchar();
        scanf("%c %d %d",&tom.c,&tom.v,&tom.time);
        getchar();
        scanf("%c %d %d",&jer.c,&jer.v,&jer.time);
        scanf("%d",&k);

        tom.x=1,tom.y=1;
        jer.x=n,jer.y=n;

        for(int i=1;i<=k;i++){
            walk(tom);
            walk(jer);
            if(panduan(tom,jer)){
                char s=tom.c;
                tom.c=jer.c;
                jer.c=s;
            }
            else{
                if(i%tom.time==0){
                change(tom);
                }
                if(i%jer.time==0){
                change(jer);
              }
            }
        //cout << tom.c << " " << jer.c << endl;
        //printf("%d %d\n%d %d\n",tom.y,tom.x,jer.y,jer.x); ///
        //cout <<endl;
        }
        printf("%d %d\n%d %d\n",tom.y,tom.x,jer.y,jer.x);
    }
    return 0;
}</span>


搭建ipv6并发代理池 我开了个知识星球,把将本期搭建写成shell脚本已放到了里面,有需要的小伙伴可以自行去取,jd的参数,阿里bxet纯算、快手滑块,Pdd—Anti,ikuai,b站login之-极验3文字,某音ab,瑞数456vmp补环境等等,主要是某些大佬加我问成品,很多人都打着白嫖的手段去加我好友为目的,问完基本就以后没有任何的交集,这样的交好友雀氏没有任何意义。不如我直接开个星球,里面直接放我逆向的成品以及逆向的思路,这样大家各取所需,我也有点收益,意义更明确点,免得浪费大家的时间。我是pve下的ubuntu。 阅读详情

相关推荐

鸿蒙实战开发教程-注册登录页面

在密码输入框中,只要设置TextInput的类型就可以实现带眼睛logo的密码输入框效果:

2401_82546228的博客 3559

hdu 4452 Running Rabbits

Running Rabbits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2    Accepted Submission(s): 2 Problem Description Rabbit Tom and

libing923的专栏 676

AUTOSAR BswM配置实战:手把手教你用Vector Davinci Configurator搭建第一个模式管理规则

本文详细介绍了如何使用Vector Davinci Configurator工具配置AUTOSAR BswM模块,实现车身控制ECU的模式管理规则。通过实战案例,从环境准备、核心概念梳理到具体配置步骤,包括ModeRequestPort、ModeCondition、Logical Expression和Rules的构建,帮助工程师快速掌握BswM配置技巧,提升汽车电子软件开发效率。

weixin_28678831的博客 351

hdu 4452 Running Rabbits(模拟水题)

Running Rabbits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 614    Accepted Submission(s): 438 Problem Description Rabbit Tom and r

记录成长的点点滴滴. . . . . 1298

告别龟速下载!保姆级教程:用离线包5分钟搞定Arduino IDE的STM32开发环境(附最新库文件)

本文提供了一套完整的Arduino IDE离线配置方案,帮助开发者5分钟快速搭建STM32开发环境。通过详细的板支持包安装指南、文件校验方法和常见问题解决方案,彻底解决GitHub下载慢的问题,提升开发效率。

weixin_26802933的博客 363

TPS563201DDCR电路翻车实录:从原理图到PCB,我踩过的5个坑及补救方法

本文详细记录了使用TPS563201DDCR电源芯片设计电路时遇到的5个常见问题及解决方案,包括EN引脚配置、BST电容选型、反馈网络设计、PCB布局优化以及散热处理。通过实际案例和数据分析,帮助工程师避免类似错误,提升电源模块的可靠性和效率。

weixin_42532938的博客 528

Running Rabbits

1 #include <iostream> 2 #include <string.h> 3 #include <string> 4 #include <fstream> 5 #include <algorithm> 6 #include <stdio.h> 7 #include <...

diwei4889的博客 219

ThingsBoard教程(十六):RPC部件的使用

前言 各位读者好,截止目前,ThingsBoard系列文章已经做了十篇,分别是 ThingsBoard教程(一):ThingBoard介绍及安装 ThingsBoard教程(二):租户,租户配置,部件组模块的使用 ThingsBoard教程(三):系统设置模块的使用 ThingsBoard教程(四):规则链简介与操作 ThingsBoard教程(五):客户,资产管理 ThingsBoard教程(六):设备管理 ThingsBoard教程(七):模拟设备遥测 ThingsBoard教程(八):自定义UI T

知无涯 4579

HDU 4452-Running Rabbits-模拟

Running Rabbits 问题描述 : Rabbit Tom and rabbit Jerry are running in a field. The field is an N×N grid. Tom starts from the up-left cell and Jerry starts from the down-right cell. The coordinat...

weixin_30435261的博客 170

【OpenClaw】Edict 三省六部制部署与启动

文章摘要 本文聚焦Edict系统的本地部署与启动,提供三种安装方式:Docker快速体验、macOS/Linux原生安装和Windows生产仿真。核心目标是让用户能够独立完成系统启动和基础问题排查,确保看板、后端服务、同步脚本和网关正常运行。文章强调环境检查的重要性,并给出具体验收标准:浏览器能访问看板页面(http://127.0.0.1:7891)和接口返回JSON数据。同时提供一键启动/停止脚本和常见问题处理建议,帮助用户快速验证部署结果。配套系列教程涵盖部署启动、使用实战、二次开发和封装版本使用等内

Mr数据杨 2901

玩转 InternVL3.5 轻量级实战:从部署到优化的全记录

玩转 InternVL3.5 轻量级实战:从部署到优化的全记录

jacke121的专栏 626

map的访问

#include<iostream> #include<map> using namespace std; int main() { map<char,int>mp; mp['c']=20; cout<<mp['c']; return 0; }

Running Snail 252

开发具有情感分析能力的AI Agent

本文将深入探讨开发具有情感分析能力的AI Agent的各个方面。我们将首先介绍情感分析的基础知识,包括定义、背景和应用领域。接着,我们将详细讲解情感分析的核心概念、数据处理方法和算法原理。随后,文章将展示如何设计情感分析系统架构,并进行项目实战,包括环境安装、源代码实现和案例分析。最后,我们将总结最佳实践和注意事项,为读者提供进一步学习的资源。情感分析(Sentiment Analysis),也称为意见挖掘,是自然语言处理(NLP)的一个分支。

SuperAGI2025 1146

HDU Running Rabbits(模拟)

/* 模拟题,做的比较有感觉 以前不太擅长做模拟题,因为总是模拟中找公式,所以往往会复杂很多 ①处,原来想直接用公式求出下一步坐标,结果太麻烦。 后来直接用一个for()循环实现,简单很多 */ #include int N; void fgo(int &d, int &x, int &y, int s) { int i; switch(d) { case

817

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

HDU4452 Running Rabbits(模拟)

题目链接题意 一个NxN的方阵。 一个机器人从左下角出发,另一个机器人从右下角出发。 机器人在撞墙的时候会掉头(turn around),在固定的时间会左转 如果两个机器人想遇,则两个机器人互换方向(只会在整数小时时相遇),且忽略此时的左转 解决模拟,使用一个类来封装一些函数,会好写好多#include<bits/stdc++.h> using namespace std;int N;struct

ZhangYang 420

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Problem A: 强悍的矩阵运算来了

Problem A: 强悍的矩阵运算来了 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 677  Solved: 437 [Submit][Status][Web Board] Description 定义一个Matrix类,用于存储一个矩阵。重载其+、*运算符,分别用于计算两个矩阵的和、乘积;重载其>运算符,用于输出和输入一个矩

追艺_年华的博客 1056

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

HDU - 4452 Running Rabbits

传送门 问题描述: Rabbit Tom and rabbit Jerry are running in a field. The field is an N×N grid. Tom starts from the up-left cell and Jerry starts from the down-right cell. The coordinate of the up-left cell is (1,1) and the coordinate of the down-right cell is (N

m0_51727949的博客 236

HDU 4452 By Assassin 模拟

Running Rabbits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1854 Accepted Submission(s): 1304Problem Description Rabbit Tom and rabbit

Assassin 727

hdu 4452 Running Rabbits (模拟—12年金华赛区现场赛K题)

Running Rabbits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 607    Accepted Submission(s): 432 Problem Description Rabbit Tom and r

Hadis_yuki 1227

Come and join us at English corner

2012.12.26 Hi all, How are you doing? Merry post-Christmas and happy upcoming New year!! I wish you had a good one this year. Our one week one time English corner is coming back! Are you excited t...

weixin_30367945的博客 254

HDU 4452 Running Rabbits (模拟)

题意:          给出 N * N 的格子,两只兔子的起点为 1 ,1 和 N ,N。          现在给这两只兔子一个出发方向,和每秒跳跃格子数和每过t秒方向就向左转这些条件。          如果这只兔子跳到一定的步数碰到了墙壁,那么就回头继续将剩余的步数跳完。如果两只兔子相遇,那么这两只兔子就互换方向,这时候如果正好需要向左转,就不需要向左转。 思路:

DT2131 430

hdu 4452 Running Rabbit(模拟)

简单模拟。 注意‘at k o'clock sharp’是k点整的意思,说明两只兔子交换速度只会fasheng

Baoli1008的专栏 571

hdu 4452 Running Rabbits (模拟)

Running Rabbits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 388    Accepted Submission(s): 284 Problem Description      

Timeclimber 490
上一篇: HDU 4451 Dressing(计数)
下一篇: HDU 5876 Sparse Graph(补图+BFS最短路)
hellohelloC
博客等级 码龄12年 15粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值