zoukankan      html  css  js  c++  java
  • 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?

    Input

    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!

    Output

    Print the cell (the row and the column where the cell is situated) where Lara ends up after she moves k times.

    Examples
    Input
    Copy
    4 3 0
    Output
    Copy
    1 1
    Input
    Copy
    4 3 11
    Output
    Copy
    1 2
    Input
    Copy
    4 3 7
    Output
    Copy
    3 2
    Note

    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-1)) printf("%lld 1
    ",1+k);
        else
        {
            k-=n-1;
            ll ans=k/(m-1);
            ll pos=k%(m-1);
            if(pos==0) printf("%lld %lld
    ",n-ans+1,ans&1?m:2);
            else printf("%lld %lld
    ",n-ans,ans&1?m+1-pos:1+pos);
        }
        return 0;
    }
  • 相关阅读:
    五小步让VS Code支持AngularJS智能提示
    AngularJS----服务,表单,模块
    AJAX 动态加载后台数据 绑定select
    连接mysql 报错 Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    MAC中向阿里云服务器上传文件
    使用Navicat连接阿里云ECS服务器上的MySQL数据库
    mysql面试题:字段中@之前字符相同且大于等于2条的所有记录
    2018 最新手机号正则(最新最全)
    php同一个用户同时只能登陆一个, 后登陆者踢掉前登陆者(排他登陆)
    php 单冒号 、双冒号的用法
  • 原文地址:https://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/8977195.html
Copyright © 2011-2022 走看看