【CodeForces 615E】Hexagons
找规律。
#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的更多相关文章
- 【38.46%】【codeforces 615E】Hexagons
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【41.43%】【codeforces 560C】Gerald's Hexagon
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
- 【Codeforces 429D】 Tricky Function
[题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...
随机推荐
- There was an internal API error.的解决办法
1.当安装应用到4s时,偶尔有些程序会报这个错误,There was an internal API error 解决办法如下: 真机运行下,项目在iOS8.0下运行正常,但是一旦换到iOS7.0和7 ...
- CLR Table-Valued函数
这几天来,努力学习了CLR的存储过程,创建与部署.从普通的存储过程,带参数,以及Output返回值等. Insus.NET今天学习一个例子,怎样实现CLR Table-Valued函数.在数据库中,我 ...
- 带参数的CLR存储过程
昨天有学习<简单创建与布署CLR存储过程>http://www.cnblogs.com/insus/p/4371762.html,知道怎样创建以及布署至SQL中去. 下面这个范例是实现CL ...
- CSS3 动画效果带来的bug
css3 动画效果比如transition:all 2s linear;这种用来计算及时的物体坐标的话会带来一定的问题 比如把一个DIV从A点移动到B点.JS为DIV.style.left=B; 但是 ...
- redis 学习笔记(3)-master/slave(主/从模式)
类似mysql的master-slave模式一样,redis的master-slave可以提升系统的可用性,master节点写入cache后,会自动同步到slave上. 环境: master node ...
- Nodejs进阶:核心模块https 之 如何优雅的访问12306
本文摘录自<Nodejs学习笔记>,更多章节及更新,请访问 github主页地址.欢迎加群交流,群号 197339705. 模块概览 这个模块的重要性,基本不用强调了.在网络安全问题日益严 ...
- 备忘:maven 错误信息: Plugin execution not covered by lifecycle configuration
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- Android开发自学笔记—1.1(番外)AndroidStudio常用功能介绍
一.界面区介绍 1.项目组织结构区,用于浏览项目文件,默认Project以Android组织方式展示. 2.设计区,默认在打开布局文件时为设计模式,可直接拖动控件到界面上实现所见即所得,下方的Desi ...
- js的offsetWidth,offsetHeight,offsetLeft,offsetTop
js的offsetWidth,offsetHeight,offsetLeft,offsetTop
- Beyond Compare 3 设置自动换行
设置自动换行方法: 在菜单栏里点击“工具”,然后在弹出列表里选择“文件格式”,在弹出框的左下角编辑文件格式默认值中,选择“文本格式”,对右侧的 ‘每行字符限制’进行修改保存即可,一般可设置80或90. ...