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

Submit
Status

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

Source

Problem Setter: Muntasir Muzahid Chowdhury
Special Thanks: Jane Alam Jan (Dataset)

#include<cstdio>
#include<cmath>
int main()
{
int t,i,a,b;
long long n;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%lld",&n);
a=sqrt(n);
b=n-a*a;
if(b==0)
{
if(a%2==0)
printf("Case %d: %d 1\n",i,a);
else
printf("Case %d: 1 %d\n",i,a);
}
else if(b==a+1)
printf("Case %d: %d %d\n",i,a+1,a+1);
else if(b<a+1)
{
if(a%2==0)
printf("Case %d: %d %d\n",i,a+1,b);
else
printf("Case %d: %d %d\n",i,b,a+1);
}
else
{
if(a%2==0)
printf("Case %d: %d %d\n",i,(a+1)*(a+1)-n+1,a+1);
else
printf("Case %d: %d %d\n",i,a+1,(a+1)*(a+1)-n+1);
}
}
return 0;
}

lightoj--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. [LOJ 1008] Fibsieve`s Fantabulous Birthday

    A - Fibsieve`s Fantabulous Birthday Time Limit:500MS     Memory Limit:32768KB     64bit IO Format:%l ...

  3. lightoj 1148 Mad Counting(数学水题)

    lightoj 1148 Mad Counting 链接:http://lightoj.com/volume_showproblem.php?problem=1148 题意:民意调查,每一名公民都有盟 ...

  4. lightoj 1010 (水题,找规律)

    lightoj 1010 Knights in Chessboard 链接:http://lightoj.com/volume_showproblem.php?problem=1010 题意:国际象棋 ...

  5. LightOJ 1166 Old Sorting 置换群 或 贪心 水题

    LINK 题意:给出1~n数字的排列,求变为递增有序的最小交换次数 思路:水题.数据给的很小怎么搞都可以.由于坐标和数字都是1~n,所以我使用置换群求循环节个数和长度的方法. /** @Date : ...

  6. LightOJ 1065 - Number Sequence 矩阵快速幂水题

    http://www.lightoj.com/volume_showproblem.php?problem=1065 题意:给出递推式f(0) = a, f(1) = b, f(n) = f(n - ...

  7. Lightoj 1112 - Curious Robin Hood 【单点改动 + 单点、 区间查询】【树状数组 水题】

    1112 - Curious Robin Hood PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 64 MB ...

  8. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

  9. D - 楼下水题(kmp+Manacher)

    D - 楼下水题 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Statu ...

随机推荐

  1. java 截取点后面的字符串

    int index = path.lastIndexOf("."); char[] ch = path.toCharArray(); //根据 copyValueOf(char[] ...

  2. 批量删除harbor中的镜像

    一 说明 这个是我第一篇博客,所以我想放上原创的东西,尽管我一直都很担心自己写得太low,但是总要学会尝试,学会改变自己,相信自己.在写这个脚本时,由于我接触LInux不是很多,能力有限,仅仅是为了让 ...

  3. LibSVM-windows

    本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50112477 官方Web: https ...

  4. [Javascript] Transduce over any Iteratable Collection

    So far we've been transducing by manually calling .reduce() on arrays, but we want to be able to tra ...

  5. hpuoj--校赛--2015年的第一场雪(暴力)

    问题 D: 感恩节KK专场--2015年的第一场雪 时间限制: 1 Sec  内存限制: 128 MB 提交: 865  解决: 76 [提交][状态][讨论版] 题目描述 下雪了,KK学长站在三教门 ...

  6. 2.IntelliJ IDEA 2017创建JavaEE项目

    转自:https://blog.csdn.net/qq_31628285/article/details/75139909?utm_source=blogxgwz0 IntelliJ IDEA 201 ...

  7. rest_framework-权限-总结完结篇

    #权限#创建一个权限类 在view添加列表 class MyPermission(object): #message 表示权限决绝时返回的数据 message = "必须是SVIP" ...

  8. Dictionary as a set of counters

    Suppose you are given a string and you want to count how many times each letters appears. There are ...

  9. sqoop配置安装以及导入

    安装sqoop的前提是已经具备java和hadoop的环境 1.上传并解压 (要导mysql的数据)得加入mysql的jdbc驱动包 接下来验证启动 Sqoop的数据导入 “导入工具”导入单个表从RD ...

  10. java9新特性-4-模块化系统: Jigsaw与Modularity

    1.官方Feature 200: The Modular JDK 201: Modular Source Code 220: Modular Run-Time Images 260: Encapsul ...