[LOJ 1008] Fibsieve`s Fantabulous Birthday
Time Limit:500MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Fibsieve had a fantabulous (yes, it's an actual word) birthday party this year. He had so many gifts that he was actually thinking of not having a party next year.
Among these gifts there was an N x N glass chessboard that had a light in each of its cells. When the board was turned on a distinct cell would light up every second, and then go dark.
The cells would light up in the sequence shown in the diagram. Each cell is marked with the second in which it would light up.
(The numbers in the grids stand for the time when the corresponding cell lights up)
In the first second the light at cell (1, 1) would be on. And in the 5th second the cell (3, 1) would be on. Now, Fibsieve is trying to predict which cell will light up at a certain time (given in seconds). Assume that N is large enough.
Input
Input starts with an integer T (≤ 200), denoting the number of test cases.
Each case will contain an integer S (1 ≤ S ≤ 1015) which stands for the time.
Output
For each case you have to print the case number and two numbers (x, y), the column and the row number.
Sample Input
3
8
20
25
Sample Output
Case 1: 2 3
Case 2: 5 4
Case 3: 1 5
题意:给出一张图,以及一个点,求出这个点的坐标
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
#define ll long long ll n; void solve()
{
ll floor=(ll)sqrt(n);
if(floor*floor!=n) floor++; //确定层数
ll dir=floor&; //确定方向,0表示左右下,1表示下上左
ll num=n-((floor-)*(floor-)); //当前层序号
if(dir==)
{
if(num<=floor)
{
printf("%lld %lld\n",num,floor);
}
else
{
num=floor-(num-floor);
printf("%lld %lld\n",floor,num);
}
}
else
{
if(num<=floor)
{
printf("%lld %lld\n",floor,num);
}
else
{
num=floor-(num-floor);
printf("%lld %lld\n",num,floor);
}
}
}
int main()
{
int T,iCase=;
scanf("%d",&T);
while(T--)
{
scanf("%lld",&n);
printf("Case %d: ",iCase++);
solve();
}
return ;
}
[LOJ 1008] Fibsieve`s Fantabulous Birthday的更多相关文章
- light oj 1008 - Fibsieve`s Fantabulous Birthday
1008 - Fibsieve`s Fantabulous Birthday PDF (English) Statistics Forum Time Limit: 0.5 second(s) Me ...
- Fibsieve`s Fantabulous Birthday LightOJ - 1008(找规律。。)
Description 某只同学在生日宴上得到了一个N×N玻璃棋盘,每个单元格都有灯.每一秒钟棋盘会有一个单元格被点亮然后熄灭.棋盘中的单元格将以图中所示的顺序点亮.每个单元格上标记的是它在第几秒被点 ...
- [LightOJ1008]Fibsieve`s Fantabulous Birthday 题解
前言 扫了一眼网上的题解,都是找规律. 估计就我一个蒟蒻在打二分. 题解 设一个" ┐"形为一层. 我们二分查找该数在那一层,然后就可以直接计算它的位置了. 代码 #include ...
- LightOJ Beginners Problems 部分题解
相关代码请戳 https://coding.net/u/tiny656/p/LightOJ/git 1006 Hex-a-bonacci. 用数组模拟记录结果,注意取模 1008 Fibsieve's ...
- lightoj刷题日记
提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...
- lightoj--1008--Fibsieve`s Fantabulous Birthday(水题)
Fibsieve`s Fantabulous Birthday Time Limit: 500MS Memory Limit: 32768KB 64bit IO Format: %lld &a ...
- LightOJ-1008-Fibsieve`s Fantabulous Birthday(推公式)
链接: https://vjudge.net/problem/LightOJ-1008 题意: Fibsieve had a fantabulous (yes, it's an actual word ...
- HDOJ 1008. Elevator 简单模拟水题
Elevator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- poj 1008:Maya Calendar(模拟题,玛雅日历转换)
Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 64795 Accepted: 19978 D ...
随机推荐
- [C#]将千分位字符串转换成数字
关键代码: /// <summary> /// 将千分位字符串转换成数字 /// 说明:将诸如"–111,222,333的千分位"转换成-111222333数字 /// ...
- javascript学习笔记3
一 判断下列数值中哪些于false相等? 0, 0.0, 0.000, -0, -0.0, 000, "0", "0.0", "0.000" ...
- Linux查看进程和终止进程的技巧
1. 在LINUX命令平台输入1-2个字符后按Tab键会自动补全后面的部分(前提是要有这个东西,例如在装了tomcat的前提下,输入tomcat的to按tab). 2. ps 命令用于查看当前正在运行 ...
- putty实现自动登录的方法(ssh和ssh2)
介绍putty实现自动登录的方法. 1.登录主机并输入ssh-keygen -t rsa 提示Enter file in which to save the key (/root/.ssh/id ...
- UDP TCP应用场景
作者:陈硕链接:https://www.zhihu.com/question/20060141/answer/26735814来源:知乎著作权归作者所有,转载请联系作者获得授权. UDP 的使用范围很 ...
- Nginx+Keepalived主备负载均衡
实验环境及软件版本: CentOS版本: 6.6(2.6.32.-504.el6.x86_64) nginx版本: nginx-1.6.2 keepalived版本:keepalived ...
- log4j记录运行日志
1.在工程中导入log4j-1.2.15.jar的jar包2.新建测试类 package control; import org.apache.log4j.Logger; import org.apa ...
- makefile的简单写法
makefile 使用方法: vi 一个Makefile文件 CC = g++ // 指的是用什么编译器RM = rm -rf // 定义一个删除的指令(变量)CFLAGS = -c -Wal ...
- C语言中宏定义(#define)时do{}while(0)的价值
最近在新公司的代码中发现到处用到do{...}while(0),google了一下,发现Stack Overflow上早有很多讨论,总结了一下讨论,加上自己的理解,do{...}while(0)的价值 ...
- Timer组件
1.常用属性 Interval 用于获取或设置Timer组件Tick事件发生的时间间隔,属性值不能小于1 制作左右飘摇窗体 private void timer1_Tick(object sender ...