找规律。

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define N 10005
#define ll long long
using namespace std;
ll n,t,x,y;
ll fx[]={,-,-,-,,,};
ll fy[]={,,,-,-,,};
int main(){
cin>>n;
if(n==){
puts("0 0");
return ;
}
t=sqrt(n/);
while(t*(t+)*>=n)t--;
x=t*;
y=;
n-=t*(t+)*;
if(n){
x+=fx[];
y+=fy[];
n--;
}
ll s=min(t,n);
x+=fx[]*s;
y+=fy[]*s;
n-=s; ll d=;
ll dx=,dy=;
t++;
while(n>=t){
dx+=fx[d];
dy+=fy[d];
d++;
printf("%lld ",d);
n-=t;
}
x+=fx[d]*n;
y+=fy[d]*n;
cout<<x+dx*t<<" "<<y+dy*t<<endl;
}

  

【CodeForces 615E】Hexagons的更多相关文章

  1. 【38.46%】【codeforces 615E】Hexagons

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  2. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  3. 【41.43%】【codeforces 560C】Gerald's Hexagon

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  5. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  6. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  7. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  8. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  9. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

随机推荐

  1. [No000043]学习Linux操作系统必备基础知识

    Linux操作系统概述 Q1.什么是GNU?Linux与GNU有什么关系? A: 1)GNU是GNU is Not Unix的递归缩写,是自由软件基金会(Free Software Foundatio ...

  2. JavaScript打开窗口与关闭页面操作大全

    JavaScript新开窗口 onClick="javascript:window.location='http://www.sowsoy.com'" JavaScript新开一个 ...

  3. java(搜索不区分大小写)

    ref.put("myfield", Pattern.compile(".*myValue.*" , Pattern.CASE_INSENSITIVE));

  4. HTML 学习笔记(块 和 类)

    HTML <div> 和 <span> 可以通过<div>和<span>将HTML元素组合起来. HTML块元素 大多数HTML元素被定义为块级元素或者 ...

  5. linux运维中的命令梳理(二)

    回想起来,从事linux运维工作已近5年之久了,日常工作中会用到很多常规命令,之前简单罗列了一些命令:http://www.cnblogs.com/kevingrace/p/5985486.html今 ...

  6. ESXi 5.5 解决 cannot edit the settings of virtual machines of version 10

    ESXi 5.5 是VMWare提供的免费虚拟服务器软件, 因为其优秀的性能, 对CPU, 内存和虚拟机数量都解除了限制, 成为很多个人或者小型公司的首选虚拟化工具. 在日常管理时常碰到的一个问题是, ...

  7. Html5 Egret游戏开发 成语大挑战(八)一般性二级页面处理

    在游戏中,我们一般会有各种各样的二级页面,比如游戏暂停界面或者游戏结束界面,这些界面组成了对玩家交互主要手段,在游戏开发中,对于这些界面的coding组织是非常有学问的,如果倒退到十年前,游戏开发的老 ...

  8. Qt学习笔记 线程(一)

    Qt中的线程是与平台无关的 QThread 提供了创建一个新线程的方法 新建一个线程,继承QThread并重写它的run()当调用 start()函数时会调用重载的run()函数 例: #ifndef ...

  9. [转]Android中Xposed框架篇—利用Xposed框架实现拦截系统方法

    一.前言 关于Xposed框架相信大家应该不陌生了,他是Android中Hook技术的一个著名的框架,还有一个框架是CydiaSubstrate,但是这个框架是收费的,而且个人觉得不怎么好用,而Xpo ...

  10. ALinq Dynamic 使用指南——前言

    一.简介 ALinq Dynamic 为ALinq以及Linq to SQL提供了一个Entiy SQL的查询接口,使得它们能够应用Entity SQL 进行数据的查询.它的原理是将Entiy SQL ...