976 B. Lara Croft and the New Game
You might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil of secrecy.
Lara is going to explore yet another dangerous dungeon. Game designers decided to use good old 2D environment. The dungeon can be represented as a rectangle matrix of n rows and m columns. Cell (x, y) is the cell in the x-th row in the y-th column. Lara can move between the neighbouring by side cells in all four directions.
Moreover, she has even chosen the path for herself to avoid all the traps. She enters the dungeon in cell (1, 1), that is top left corner of the matrix. Then she goes down all the way to cell (n, 1) — the bottom left corner. Then she starts moving in the snake fashion — all the way to the right, one cell up, then to the left to the cell in 2-nd column, one cell up. She moves until she runs out of non-visited cells. n and m given are such that she always end up in cell (1, 2).
Lara has already moved to a neighbouring cell k times. Can you determine her current position?
The only line contains three integers n, m and k (2 ≤ n, m ≤ 109, n is always even, 0 ≤ k < n·m). Note that k doesn't fit into 32-bit integer type!
Print the cell (the row and the column where the cell is situated) where Lara ends up after she moves k times.
4 3 0
1 1
4 3 11
1 2
4 3 7
3 2
Here is her path on matrix 4 by 3:
找规律
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 0x3f3f3f3f
#define mem(a) ((a,0,sizeof(a)))
typedef long long ll;
ll n,m,k;
int main()
{
scanf("%lld%lld%lld",&n,&m,&k);
if(k<=(n-)) printf("%lld 1\n",+k);
else
{
k-=n-;
ll ans=k/(m-);
ll pos=k%(m-);
if(pos==) printf("%lld %lld\n",n-ans+,ans&?m:);
else printf("%lld %lld\n",n-ans,ans&?m+-pos:+pos);
}
return ;
}
976 B. Lara Croft and the New Game的更多相关文章
- 【ZOJ2276】Lara Croft(bfs)
BUPT2017 wintertraining(16) #4 D ZOJ - 2276 题意 n个数字绕成环,有两个指示数字的方块,每次可以顺时针或逆时针移动其中一个,步数是它当前位置的数字a[i], ...
- 五、Pandas玩转数据
Series的简单运算 import numpy as np import pandas as pd s1=pd.Series([1,2,3],index=['A','B','C']) print(s ...
- PHP操作MongoDB学习(转)
1 mongodb启动时,设置启动项 C:\>mongodb\bin\mongod --config C:\mongodb.conf 其中mongodb.conf为: dbpath = ...
- UVa 10361 Automatic Poetry
Automatic Poetry Input: standard input Output: standard output Time Limit: 2 seconds Memory Limit: 3 ...
- UVA10361 - Automatic Poetry
“Oh God”, Lara Croft exclaims, “it’s one of these dumb riddles again!” In Tomb Raider XIV, Lara is, ...
- Tomb Raider
Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her ...
- ARTIFICIAL INTELLIGENCE FOR GAMES (Ian Millington / John Funge 著)
相关网站:http://www.ai4g.com PART I AI AND GAMESCHAPTER1 INTRODUCTIONCHAPTER2 GAME AIPART II TECHNIQUESC ...
- ACM/ICPC 2018亚洲区预选赛北京赛站网络赛-B:Tomb Raider(二进制枚举)
时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Lara Croft, the fiercely independent daughter of a missing adv ...
- hihocoder 1829 - 压缩字符串 - [状压+暴力枚举][2018ICPC北京网络预赛B题]
题目链接:https://hihocoder.com/problemset/problem/1829 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Lara Croft, ...
随机推荐
- Android开发之视图动画基础
Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转移旋转 ...
- httpClient模拟登陆校内某系统
package com.huowolf; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpE ...
- ServiceStack.Redis之IRedisClient<第三篇>【转】
事实上,IRedisClient里面的很多方法,其实就是Redis的命令名.只要对Redis的命令熟悉一点就能够非常快速地理解和掌握这些方法,趁着现在对Redis不是特别了解,我也对着命令来了解一下这 ...
- Nashorn——在JDK 8中融合Java与JavaScript之力--转
原文地址:http://www.infoq.com/cn/articles/nashorn 从JDK 6开始,Java就已经捆绑了JavaScript引擎,该引擎基于Mozilla的Rhino.该特性 ...
- 如何用一个app操作另外一个app.比如微信群控那样的
如何实现一个app.控制另外的app,比如市面上群控微信的,是用测试工具的原理?还是什么模拟点击的原理? 如何用一个app操作另外一个app.比如微信群控那样的 >> android这个答 ...
- SpringCloud学习笔记(12)----Spring Cloud Netflix之Hystrix断路器的流程和原理
工作流程(参考:https://github.com/Netflix/Hystrix/wiki/How-it-Works) 1. 创建一个HystrixCommand或HystrixObservabl ...
- Java中hashCode与equal方法详解
转载自http://blog.csdn.net/jiangwei0910410003/article/details/22739953 Java中的equals方法和hashCode方法是Object ...
- HDU-5685 Problem A 求乘法逆元
题目链接:https://cn.vjudge.net/problem/HDU-5685 题意 给一个字符串S和一个哈希算法 $ H(s)=\prod_{i=1}^{i\leq len(s)}(S_{i ...
- Edward Frenkel关于几何化朗兰兹纲领的采访
本文来自:菲尔兹奖座谈会 博客 Edward Frenkel教授的主要研究方向是数学与量子物理中的对称.他现在在做的许多问题都与朗兰兹纲领有关.他现在是加州大学伯克利分校的数学教授. 在今年的菲尔兹奖 ...
- C语言中头文件尖括号和引号的区别
用include 引用头文件时,双引号和尖括号的区别: 1.双引号:引用非标准库的头文件,编译器首先在程序源文件所在目录查找,如果未找到,则去系统默认目录查找,通常用于引用用户自定义的头文件. 2.尖 ...