UVA 10161 - Ant on a Chessboard(数学)

SolidWorks 2022 学习(一)软件安装 接下来是安装SolidWorks,右键SolidWorks.2022.SP0.Premium.DVD.iso,选择装载。然后以管理员身份运行SolidWorks_Flexnet_Server目录下的server_install.bat。更改需要安装的产品,以及安装路径,并勾选接受条款,点击现在安装,会弹出如下窗口。然后以管理员身份运行setup.exe,开始安装solidworks。下载链接会在文章末尾给出,下载完成的文件如下图所示。双击注册表文件,然后点击确定。保持不动,点击确定,开始安装。 阅读详情

 

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;
}


关于机器人精度的总结(重复精度和绝对精度区分) 机械臂是工业生产中的重要设备,在焊接码垛 以及 非 接触测量等 领域中有 着重要应 用。然而由于机械臂本体制造中存在机械制造公差装配误差导致的运动学参数误差以及电机转角与关节转角间减速比误差等,导致机械臂存在。因此需要对机械臂进行标定,提高机械臂的绝对定位精度。ABB系列某款机器人精度参数表。 阅读详情

相关推荐

ElasticSearch集群搭建

docker安装es集群

weixin_46562226的博客 2025

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 681

基于CANoe的Basic Diagnostics ECU (UDS)

基于CANoe的Basic Diagnostics ECU (UDS)

farmer00的博客 9153

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 如表格,矩阵是从

水果君の日常 1749

AI视频生成提示词工程:结构化公式与实战案例详解

在实际使用 AI 生成视频或图像时,最常遇到的困惑是:为什么我的提示词(Prompt)生成的画面总是不理想?是模型能力不足,还是我的描述有问题?答案往往是后者。提示词工程(Prompt Engineering)并非简单的“翻译”需求,而是一门需要结构化思维和精准描述的技能。它决定了 AI 能否准确理解你的意图,并生成符合预期的视觉内容。 本文将通过两个核心案例,深入拆解提示词的构建逻辑。第一个案例聚焦于“文生视频”,我们将学习如何将一个简单的想法,如“小猫在雪地里玩雪球”,通过结构化公式扩展为一段富有细节和

weixin_30800987的博客 563

第1章>>1.5:神电测控为什么开发LabVIEW ZYNQ FPGA软件工具包?(ZYNQ芯片的特点与优势)《LabVIEW ZYNQ FPGA宝典》

ZYNQ是赛灵思公司(Xilinx)推出的新一代全可编程片上系统(APSoC,All-Programmable SoC),它将处理器的软件可编程性与FPGA的硬件可编程性进行完美整合,以提供无与伦比的系统性能、灵活性与可扩展性。Zynq-7000系列是Xilinx于2010年4月推出的行业第一个可扩展处理平台,旨在为视频监视、汽车驾驶员辅助、工厂自动化、医疗器械等高端嵌入式应用提供所需的处理能力与计算性能。这款基于ARM处理器的SoC可满足复杂嵌入式系统的高性能、低功耗和多核处理能力等要求。

qq_40694786的博客 1647

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

基于深度学习的垃圾邮件识别

垃圾邮件的大量存在严重威胁着电子邮件系统的安全和效率。基于深度学习的垃圾邮件识别技术已经成为目前最有效的解决方案之一。本文将详细介绍使用深度学习技术进行垃圾邮件识别的方法,并提供相应的代码实现。 随着电子邮件的广泛应用,垃圾邮件的数量不断增加,传统的规则和统计方法已经无法满足对垃圾邮件进行准确识别的需求。深度学习技术以其强大的模式识别能力和自动特征提取能力成为解决垃圾邮件识别难题的有效工具。

一键难忘的博客 1093

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

有一种力量叫乐观 431

【PCIe 总线及设备入门学习专栏 6.1 -- PCIe MCTP】

MCTP 是由 DMTF(Distributed Management Task Force)定义的协议,用于提供设备和主机间基于不同传输层(如 PCIe、I²C、USB 等)的管理消息通信能力。在 PCIe 环境下,MCTP 消息作为的一种特殊形式传输,并被赋予唯一的 VDM Code 值0000b,以区别于其他 VDM。MCTP 在 PCIe 环境中作为一种基于 Type 1 VDM 的管理通信协议,提供了设备与主机之间的灵活数据传输能力。

CodingCos的博客 2128

YOLOv11改进策略【卷积层】| 引入注意力卷积模块RFAConv,关注感受野空间特征 助力yolov11精度提升

RFAConv:创新空间注意力和标准卷积运算感受野空间特征是针对卷积核设计的,根据卷积核大小动态生成。以3×3卷积核为例,它由非重叠滑动窗口组成,每个窗口代表一个感受野滑块。

Limiiiing的博客 1823

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

claude code desktop中出现Doesn‘t look like an Anthropic model - expected a gateway model route 解决方案

本文主要介绍了claude code desktop中出现Doesn’t look like an Anthropic model - expected a gateway model route referencing an Anthropic model和Server is busy. Retrying的解决方案,希望能对使用claude code desktop的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 9万+

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

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

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

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

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;

对酒当歌 1075

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

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/ 1199

UVa 10161 Ant on a Chessboard

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

u014491224的专栏 755

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,邱秋

寂静山林 1961

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

小华在努力~ 624

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的博客 402

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的专栏 795

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的小博客 96
上一篇: 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、付费专栏及课程。

余额充值