A - Fibsieve`s Fantabulous Birthday

Time Limit:500MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu

Description

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的更多相关文章

  1. light oj 1008 - Fibsieve`s Fantabulous Birthday

    1008 - Fibsieve`s Fantabulous Birthday   PDF (English) Statistics Forum Time Limit: 0.5 second(s) Me ...

  2. Fibsieve`s Fantabulous Birthday LightOJ - 1008(找规律。。)

    Description 某只同学在生日宴上得到了一个N×N玻璃棋盘,每个单元格都有灯.每一秒钟棋盘会有一个单元格被点亮然后熄灭.棋盘中的单元格将以图中所示的顺序点亮.每个单元格上标记的是它在第几秒被点 ...

  3. [LightOJ1008]Fibsieve`s Fantabulous Birthday 题解

    前言 扫了一眼网上的题解,都是找规律. 估计就我一个蒟蒻在打二分. 题解 设一个" ┐"形为一层. 我们二分查找该数在那一层,然后就可以直接计算它的位置了. 代码 #include ...

  4. LightOJ Beginners Problems 部分题解

    相关代码请戳 https://coding.net/u/tiny656/p/LightOJ/git 1006 Hex-a-bonacci. 用数组模拟记录结果,注意取模 1008 Fibsieve's ...

  5. lightoj刷题日记

    提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...

  6. lightoj--1008--Fibsieve`s Fantabulous Birthday(水题)

    Fibsieve`s Fantabulous Birthday Time Limit: 500MS   Memory Limit: 32768KB   64bit IO Format: %lld &a ...

  7. LightOJ-1008-Fibsieve`s Fantabulous Birthday(推公式)

    链接: https://vjudge.net/problem/LightOJ-1008 题意: Fibsieve had a fantabulous (yes, it's an actual word ...

  8. HDOJ 1008. Elevator 简单模拟水题

    Elevator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  9. poj 1008:Maya Calendar(模拟题,玛雅日历转换)

    Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 D ...

随机推荐

  1. HDU 1058 Humble Number

    Humble Number Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humbl ...

  2. error C2664 转换错误汇总[转]

    vs2005提示 error C2664: “CWnd::MessageBoxW”: 不能将参数 1 从“const char [17]”转换为“LPCTSTR”. 在用vs2005编写mfc程序的时 ...

  3. asp.net导出excel较为简约的代码

    ds为数据源 Response.Buffer = true; Response.AppendHeader("Content-Disposition", "attachme ...

  4. JavaScript 对象的几种创建方法

    /** * Created by 2016 on 2016/6/4. */ function Box(){ var obj = new obj(); obj.name = "Lee" ...

  5. php 加密解密方法2

    <?php /* * @param $string 要加密或解决的字符串 * @param $operation 加密/解密 ENCODE加密, DECODE 解密 * @param $key ...

  6. 如何使用 require.js ,实现js文件的异步加载,避免网页失去响应,管理模块之间的依赖性,便于代码的编写和维护。

    一.为什么要用require.js? 最早的时候,所有Javascript代码都写在一个文件里面,只要加载这一个文件就够了.后来,代码越来越多,一个文件不够了,必须分成多个文件,依次加载.下面的网页代 ...

  7. CANVAS运用-对图片的压缩上传(仅针对移动浏览器)

    最近在移动端设计头像上传功能时,原本是以<input type="file">直接通过formData上传,然而实际使用情况是:对于过大的图片(高像素手机所拍摄的照片等 ...

  8. 一步步学习ASP.NET MVC3 (4)——Razor(2)

    请注明转载地址:http://www.cnblogs.com/arhat 在上一章,我们介绍了Razor的一些基本语法,从Razor中我们可以出ASP.NET MVC的视图引擎给我们带来的便利,但是同 ...

  9. jquery upload

    http://blueimp.github.io/jQuery-File-Upload/ https://github.com/blueimp/jQuery-File-Upload/wiki Back ...

  10. Spring+MyBatis实践—工程配置

    初次实践:Spring+MyBatis技术搭建框架,采用Bootstrap前端开源框架. 简介: MyBatis是支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis 消除 了几乎所 ...