找规律。

#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. 隐写技巧——利用JPEG文件格式隐藏payload

    0x00 前言 继续对图片隐写技巧的学习,这次是对JPEG文件格式的学习和理解.同PNG文件的格式对比,JPEG文件相对简单,读取其中隐藏payload的方式大同小异,两者区别在于文件格式不同,可供利 ...

  2. 网络流-最大流问题 ISAP 算法解释(转自Renfei Song's Blog)

    网络流-最大流问题 ISAP 算法解释 August 7, 2013 / 编程指南 ISAP 是图论求最大流的算法之一,它很好的平衡了运行时间和程序复杂度之间的关系,因此非常常用. 约定 我们使用邻接 ...

  3. $.data(data , "")

    今天在二次开发的时候,看到源代码的新闻列表是Aajax获取的,点击新闻内容触发编辑,我没有看到新闻Id却能查到信息. 观看$.ajax遍历赋值过程中,$tr("<a>新闻内容&l ...

  4. cocos 锚点、包围盒

    cocos中,setPosition就是设置一个sprite的锚点在父级元素的坐标 默认锚点是sprite矩形的中点 可以用getBoundingBox返回一个sprite所占矩形范围.范围用Rect ...

  5. http协议(七)通用首部字段

    通用首部字段的意思,就是:请求和响应报文双方都会使用的首部 1.Cache-Control 通过指定它的指令,能操作缓存的工作机制 指令参数是可选的,多个指令通过“,”分隔 Cache-Control ...

  6. [Cache] C#操作缓存--CacheHelper缓存帮助类 [复制链接]

    using System;using System.Web;using System.Collections; namespace DotNet.Utilities{ public class Cac ...

  7. XAMPP部署

    1,直接从官网上下载,然后安装即可 2,出现的问题: a,启动Apache服务器的时候,出现打开端口失败,原因80号端口已被占用,解决方案,更改config文件,将端口设置为8090 b,给phpmy ...

  8. C#中excel导入sql

    using Microsoft.Office.Interop.Excel; public int ledinExcel(string file, object sender, EventArgs e) ...

  9. 2016.11.14测试 长乐一中2014NOIP复赛模拟题 第一题。

    1.正确答案 [题目描述] 小H与小Y刚刚参加完UOIP外卡组的初赛,就迫不及待的跑出考场对答案. "吔,我的答案和你都不一样!",小Y说道,"我们去找神犇们问答案吧&q ...

  10. ASP.NET 中执行 URL 重写

    具体实现步骤(其中的一种实现方法): 一.下载相关的DLL(ActionlessForm.dll和UrlRewriter.dll) http://download.csdn.net/detail/yi ...