找规律。

#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. Zookeeper的学习材料

    https://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper/ https://www.zhihu.com/question/351 ...

  2. Linux强化论:15步打造一个安全的Linux服务器

    Linux强化论:15步打造一个安全的Linux服务器 Alpha_h4ck2016-11-30共28761人围观 ,发现 8 个不明物体专题系统安全 可能大多数人都觉得Linux是安全的吧?但我要告 ...

  3. 未找到数据,异常处理:exception when no_data_found then 异常处理语句;

    未找到数据. 在 select 字段 Into 变量 from 表 where 条件: 这种语句中很有可能会有select 不到数据的问题,导致报错"未找到数据" 要解决这种问题需 ...

  4. Nginx+keepalived双机热备(主从模式)

    负载均衡技术对于一个网站尤其是大型网站的web服务器集群来说是至关重要的!做好负载均衡架构,可以实现故障转移和高可用环境,避免单点故障,保证网站健康持续运行.关于负载均衡介绍,可以参考:linux负载 ...

  5. C语言--指向多维数组的指针和指针数组

    #include <stdio.h> //void show(char *p[]); ]); int main(){ ][]={","abc","x ...

  6. DEDECMS之四 栏目调用

    一.内容页调用 {dede:type} <a href=" [field:typelink /] "> [field:typename/] </a> {/d ...

  7. html中label宽度设置、非替换元素和替换元素

    <label ></label> 单独对label设置一个width:100px的属性石不起作用的,和float:left或者display:inline-block配合的话 ...

  8. 如何迁移Alwayson AG

    Windows cluster要求同一个cluster中的所有windows版本都是相同的,这样就出现一个问题,当我们要将对windows进行升级时,(例如从windows 2008 R2升级到win ...

  9. noi题库(noi.openjudge.cn) 1.7编程基础之字符串T31——T35

    T31 字符串P型编码 描述 给定一个完全由数字字符('0','1','2',-,'9')构成的字符串str,请写出str的p型编码串.例如:字符串122344111可被描述为"1个1.2个 ...

  10. Wabpack系列:在webpack+vue开发环境中使用echarts导致编译文件过大怎么办?

    现象,在一个webpack+vue的开发环境中,npm install echarts --save了echarts,然后在vue文件中直接使用 import echarts from 'echart ...