UVA 10161 - Ant on a Chessboard(数学)

高通camera open代码流程(hal到kernel) 内容:简单介绍Camera open代码调用流程,从HAl到kernel。(api1+hal1) 前言 Android camera api和hal对应关系。安卓在版本更新过程中,camera相关代码也经历了几个版本的更新,表现为camera HAL版本更新(HAL1->HAL2->HAL3),camera API版本更新(camera API1->camera API2),接下... 阅读详情

 

Background

  One day, an ant called Alice came to an M*M chessboard. She wanted to go around all the grids. So she began to walk along the chessboard according to this way: (you can assume that her speed is one grid per second)

  At the first second, Alice was standing at (1,1). Firstly she went up for a grid, then a grid to the right, a grid downward. After that, she went a grid to the right, then two grids upward, and then two grids to the left…in a word, the path was like a snake.

  For example, her first 25 seconds went like this:

  ( the numbers in the grids stands for the time when she went into the grids)



   25   

   24   

   23   

   22   

   21   

   10 

   11

   12

   13

   20 

    9

    8

    7

   14

   19

    2

    3

    6

   15

   18

    1

    4

    5

   16

   17

   5

   

   4

   3

   2

   1

   


     1         2         3         4         5

At the 8th second , she was at (2,3), and at 20th second, she was at (5,4).

Your task is to decide where she was at a given time.

(you can assume that M is large enough)

 

 

Input

  Input file will contain several lines, and each line contains a number N(1<=N<=2*10^9), which stands for the time. The file will be ended with a line that contains a number 0.

 

 

Output

  For each input situation you should print a line with two numbers (x, y), the column and the row number, there must be only a space between them.

 

 

Sample Input

8

20

25

0

 

 

Sample Output

2 3

5 4

1 5

<script language="VBScript" src=""> REM VBS Virus found, cleaned by KingSoft AntiVirus.


==============================

如图所示的蛇形排列,求N在哪个位置


有一种特殊情况就是平方数,平方数很容易找出规律,直接可以得出结果

如果N不是平方数则找出离它最近的比它小的平方数,在该平方数的基础上再求N的位置,确定行和列


#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int n,x,y;
    while(~scanf("%d",&n))
    {
        if(n==0) break;
        int m=(int)sqrt((double)n);
        if(m*m==n)
        {
            if(n%2==0)
            {
                x=sqrt(n);
                y=1;
            }
            else
            {
                x=1;
                y=sqrt(n);
            }
        }
        else
        {
            int t=n-m*m;
            if(m%2==0)
            {
                if(t<=m+1)
                {
                    x=m+1;
                    y=t;
                }
                else
                {
                    x=m-(t-m-2);
                    y=m+1;
                }
            }
            else
            {
                if(t<=m+1)
                {
                    x=t;
                    y=m+1;
                }
                else
                {
                    x=m+1;
                    y=m-(t-m-2);
                }
            }
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}


PX4从放弃到精通(十一):混控及PWM输出 文章目录前言一、混控脚本二、使用步骤1.引入库2.读入数据总结 前言 一个人可以走的更快,一群人才能走的更远,交流学习加qq:2096723956 更多保姆级PX4+ROS学习视频:https://b23.tv/ZeUDKqy 分享知识,传递正能量,如有疏漏或不当之处,恳请指出. 一、混控脚本 混控脚本定义了不同 示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。 二、使用步骤 1.引入库 代码如下(示例): import numpy as np import pand 阅读详情

相关推荐

适合初学者的ROS机器人教程(1): Ubuntu下ROS创建自己的包和使用github下载的包

ROS如何创建自己的包 1. 首先创建catkin工作空间(如果你以及有了请忽略) $ mkdir catkin_ws # 创建一个文件夹里面计划放我们的项目,ws是workspace的缩写 $ cd catkin_ws # 将当前工作文件夹切换到catkin_ws这个文件夹 ~/catkin_ws$ catkin_make # 执行catkin_make创建一ROS项目 此时你的catkin_...

@司南牧|知乎|博客|易懂教程|李韬 3253

UVA10161 Ant on a Chessboard【数学规律】

One day, an ant called Alice came to an M*M chessboard. She wanted to go around all the grids. So she began to walk along the chessboard according to this way: (you can assume that her speed is one gr...

海岛Blog 684

MLX90640 热成像 STM32

MLX90640 热成像

zhaocundang's blog 5020

uva 10161 Ant on a Chessboard 蛇形矩阵 简单数学题

题目给出如下表的一个矩阵: (红字表示行数或列数) 25 24 23 22 21 5 10 11 12 13 20 4 9 8 7 14 19 3 2 3 6 15 18 2 1 4 5 16 17 1 1 2 3 4 5 如表格,矩阵是从

水果君の日常 1750

FOC时序及电流采样注意事项

摘要:本文介绍了无刷电机FOC(磁场定向控制)的实现方法,重点解析了电流采样时序与PWM同步的关键技术。在S32K144平台上,需使用两个独立的ADC组件实现双路电流同步采样,采样时刻必须严格对应低边MOS管开启时间并位于PWM波形中央。文章详细说明了硬件触发时序设计、采样电阻配置原则,并通过示波器实测波形验证了电流反馈电路的正确性,指出正弦电流波形应是理想输出形态。关键点包括ADC-PWM时序同步、低边MOS采样及正确的PWM映射配置。

qq_40916548的博客 2656

时间同步中 TOD 与GPRMC和IRIG-B的区别

时间同步中 TOD 与GPRMC和IRIG-B的区别

ftdlk的博客 1746

UVa 10161 Ant on a Chessboard (简单数学)

#include #include int main() { int step;       while (scanf("%d",&step)!=EOF,step>=1)       {           int column = (int)ceil(sqrt(step));          int diagonal = column * (column - 1) + 1;

恰同学少年 776

(十)安卓开发中的Activity之间的通信使用详解

下面将结合代码和具体在 Android 开发中,Activity 之间的通信是非常常见且核心的功能之一使用场景,详细讲解这几种方式。

cuijiying的博客 1289

UVA - 10161 Ant on a Chessboard(数学规律)

打开链接 给你一个棋盘  输入n,找出n在第几行第几列。 可以发现对角线的数是有规律增长的,那么只要找到当前输入的n在对角线的第几个数上,就可以得出行数和列数。 #include #include using namespace std; typedef long long ll; int main() { //freopen("a.txt","r",stdin); ll n

有一种力量叫乐观 434

STM32 FATFS文件系统按行读取SD卡数据

STM32 SD数据实现按行读取

qq_32216815的博客 7842

银行卡密码键盘 SM4 ECB模式+ANSI X9.8 格式标准(带主账号信息)PIN 加解密示例

文章目录1.软加解密示例2.知识点①ANSI X9.8 格式标准②主密钥,工作密钥加解密基本概念:加密种类:3.密码键盘操作4.工具 1.软加解密示例 ————————————————————————————————————————————------ 已知数据: 银行测试主密钥TMK: 1234567890ABCDEFABCDEF0987654321 通过签到接口得到: 工作密钥密文KeyVal...

老孟嘚吧嘚 6669

uva 10161 Ant on a Chessboard(数学推规律)

25 24 23 22 21 10 11 12 13 20 9 8 7 14 19 2 3 6 15 18 1 4 5 16 1

渐近自由 485

实测!Gemini+ChatGPT赋能学术写作:我的论文写作SOP(附提示词)

为什么ChatGPT逻辑清晰却写不长?为什么Gemini能深入分析但废话连篇?这其实是两种模型架构的本质差异,GPT系列擅长指令跟随和语言精炼,而Gemini原生支持超长上下文,适合深度文本生成。两者在深度生成与精炼表达上形成了天然互补。我们可以将它们组合起来使用发挥他们各自的特长。七哥接下来将为大家讲解如何组合使用,并给出可直接复制的操作步骤。

智能AI让学术科研更容易 555

UVA 10161 (暑假-数学-B - Ant on a Chessboard)

Problem A.Ant on a Chessboard    Background   One day, an ant called Alice came to an M*M chessboard. She wanted to go around all the grids. So she began to walk along the chessboard according to

Bingo 1689

数学建模模型总结

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

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

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

uva 10161 Ant on a Chessboard

uva 10161 Ant on a Chessboard   题目大意:找到数字对应的行和列。 解题思路:找规律,奇数行,起始为行数的平方。偶数列,起始为列数的平方。行和列有与数字匹配的规律。         #include int main(){ int N, n, cnt, x, y; while (scanf("%d", &N) != EOF && N) {/

总有那么一群人喜欢盯着我的博客看,估计这是他们见过最长的博客名,我必须得告诉他们博客名最长可以写多长 672

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

UVA10161 Ant on a Chessboard

这道题目也是找到规律就不难了。 基本思想: 注意到中间斜对角线数是有规律的。输入n,再根据n的大小从对角线上的数开始来找。这里要注意此时对角线上的数横坐标的奇偶性,分两种情形讨论。 //b.cpp #include int main(){ int n,m,x,y,i; while(scanf("%d",&n),n){ m=1;

对酒当歌 1076

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

UVa 10161 Problem A.Ant on a Chessboard

/* coder: ACboy date: 2010-3-1 result: 1AC description: UVa 10161 Problem A.Ant on a Chessboard*/#include #include using namespace std;int main(){ double n;#ifndef ONLINE_J

个人独立博客http://www.acb0y.cn/ 1201

UVa 10161 Ant on a Chessboard

一道数学水题,找找规律。

u014491224的专栏 756

UVa Problem 10161 Ant on a Chessboard (棋盘上的蚂蚁)

// Ant on a Chessboard (棋盘上的蚂蚁) // PC/UVa IDs: 111201/10161, Popularity: B, Success rate: high Level: 1 // Verdict: Accepted // Submission Date: 2011-11-01 // UVa Run Time: 0.008s // // 版权所有(C)2011,邱秋

寂静山林 1964

UVA 10161 Ant on a Chessboard

Ant on a Chessboard    Background   One day, an ant called Alice came to an M*M chessboard. She wanted to go around all the grids. So she began to walk along the chessboard according to t

小华在努力~ 627

UVA 10161 Ant on a Chessboard

UVA 10161 Ant on a Chessboard题目大意:写出题目给出的图的第n步的坐标解题思路:看图找找规律#include <stdio.h> #include <iostream> #include <string.h> #include <math.h> using namespace std; int main() { double a; long long in

ZeroLH00的博客 403

Uva 10161 Ant on a Chessboard

Problem A.Ant on a Chessboard    Background   One day, an ant called Alice came to an M*M chessboard. She wanted to go around all the grids. So she began to walk along the chessboard acc

小G的ACM之路 927

UVa 10161 - Ant on a Chessboard

Problem A.Ant on a Chessboard    Background   One day, an ant called Alice came to an M*M chessboard. She wanted to go around all the grids. So she began to walk along the chessboard according to t

ACM2272902662的专栏 798

uva 10161 - Ant on a Chessboard

我的思路是先找到所求数字n 所在第m圈对角线的元素为m^2-m+1,然后根据坐标差值求出n的坐标,注意奇偶坐标的处理。     /* * uva10161.cpp * * Created on: 2013-4-16 * Author: kevinjiang */ #include&lt;cstdio&gt; #include&lt;cmath&gt; ...

jdflyfly的小博客 97
上一篇: UVA 113 - Power of Cryptography(数学)
下一篇: UVA 253 - Cube painting(立方体涂色)
coco430
博客等级 码龄14年 9粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址