博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #338 (Div. 2) E. Hexagons 讨论讨论
阅读量:7026 次
发布时间:2019-06-28

本文共 1085 字,大约阅读时间需要 3 分钟。

E. Hexagons

题目连接:

Description

Ayrat is looking for the perfect code. He decided to start his search from an infinite field tiled by hexagons. For convenience the coordinate system is introduced, take a look at the picture to see how the coordinates of hexagon are defined:

Ayrat is searching through the field. He started at point (0, 0) and is moving along the spiral (see second picture). Sometimes he forgets where he is now. Help Ayrat determine his location after n moves.

Input

The only line of the input contains integer n (0 ≤ n ≤ 1018) — the number of Ayrat's moves.

Output

Print two integers x and y — current coordinates of Ayrat coordinates.

Sample Input

3

Sample Output

-2 0

Hint

题意

有一个人会在坐标上按照六边形那样走,会一直走下去

问你走了n步之后,这个人会在哪儿。

题解:

就不停的讨论讨论……

首先我们先确定他在第几个环上,我们将环切成6份,然后再看他在哪一份上

然后再计算就好了……

不停讨论讨论

代码

#include
using namespace std;int main(){ long long n; while(scanf("%lld",&n)!=EOF){ if(n==0)return puts("0 0"); n--; for(long long i=1;;i++) { long long cnt = i*6; if(n>=cnt)n-=cnt; else { if(n

转载地址:http://ksoxl.baihongyu.com/

你可能感兴趣的文章
yii2中如何使用modal弹窗之基本使用
查看>>
mongodb怎么删除数据库?
查看>>
什么是CIO什么是CTO
查看>>
用CMake 打包 deb包
查看>>
首家5G体验厅在深圳建成
查看>>
腾讯面试Android高级岗。居然被一个多线程基础面倒了?
查看>>
什么是网站SEO优化?为什么说要定时更新站内文章
查看>>
Interface Builder(简称IB,界面构建器)
查看>>
linux学习笔记:dstat命令详解
查看>>
我的友情链接
查看>>
Java中的图型报表---折现图(代码)
查看>>
web前端工具收集
查看>>
19.12添加自定义监控项目19.13/19.14 配置邮件告警19.15 测试告警19.16 不发邮件的问题处理...
查看>>
bottle框架学习(二)之HTTP请求
查看>>
java 构造方法总结
查看>>
The content of elements must consist of well-formed character data or markup解决方法
查看>>
详解Linux运维工程师高级篇(大数据安全方向)
查看>>
如何批量下载PDF
查看>>
8月第三周网络安全报告:放马站点域名423个
查看>>
k8s集群之日志收集EFK架构
查看>>