lightoj--1008--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
Source
- #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(水题)的更多相关文章
- light oj 1008 - Fibsieve`s Fantabulous Birthday
1008 - Fibsieve`s Fantabulous Birthday PDF (English) Statistics Forum Time Limit: 0.5 second(s) Me ...
- [LOJ 1008] Fibsieve`s Fantabulous Birthday
A - Fibsieve`s Fantabulous Birthday Time Limit:500MS Memory Limit:32768KB 64bit IO Format:%l ...
- lightoj 1148 Mad Counting(数学水题)
lightoj 1148 Mad Counting 链接:http://lightoj.com/volume_showproblem.php?problem=1148 题意:民意调查,每一名公民都有盟 ...
- lightoj 1010 (水题,找规律)
lightoj 1010 Knights in Chessboard 链接:http://lightoj.com/volume_showproblem.php?problem=1010 题意:国际象棋 ...
- LightOJ 1166 Old Sorting 置换群 或 贪心 水题
LINK 题意:给出1~n数字的排列,求变为递增有序的最小交换次数 思路:水题.数据给的很小怎么搞都可以.由于坐标和数字都是1~n,所以我使用置换群求循环节个数和长度的方法. /** @Date : ...
- LightOJ 1065 - Number Sequence 矩阵快速幂水题
http://www.lightoj.com/volume_showproblem.php?problem=1065 题意:给出递推式f(0) = a, f(1) = b, f(n) = f(n - ...
- Lightoj 1112 - Curious Robin Hood 【单点改动 + 单点、 区间查询】【树状数组 水题】
1112 - Curious Robin Hood PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 64 MB ...
- ACM水题
ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...
- D - 楼下水题(kmp+Manacher)
D - 楼下水题 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Statu ...
随机推荐
- LayUI加载js无效问题
在部署系统的时候,本地调试一切正常,layer.js均能正常加载.然而部署到服务器之后,经常性的出现layer.js无法加载问题.导致页面弹框无法使用. 一开始以为是Google浏览器问题,因为刚刚更 ...
- 洛谷 P1088 火星人 (全排列)
直接调用next_permutation即可,向前的话可以调用prev_permutation #include<cstdio> #include<cctype> #inclu ...
- PID三种参数的理解
来源:http://blog.gkong.com/liaochangchu_117560.ashx PID是比例.积分.微分的简称,PID控制的难点不是编程,而是控制器的参数整定.参数整定的关键是正确 ...
- 洛谷 P2183 巧克力
P2183 巧克力 题目描述 佳佳邀请了M个同学到家里玩.为了招待客人,她需要将巧克力分给她的好朋友们.她有N(1<=N<=5000)块巧克力,但是大小各不一样,第i块巧克力大小为为1*X ...
- Android笔记——Activity中的数据传递案例(用户注冊)
1.创建程序activity_main: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/andro ...
- Compile OpenCASCADE7.3 with VS2008
Compile OpenCASCADE7.3 with VS2008 eryar@163.com 概述 在OpenCASCADE的源码文件夹中有个adm文件夹,里面提供了各个平台中编译源码的项目文件. ...
- Linux/UNIX线程(1)
线程(1) 本文将介绍怎样使用多个控制线程在单个进程环境中运行多个任务. 一个进程中的全部线程都能够訪问该进程的组成部件(如文件描写叙述符和内存). 线程包含了表示进程内运行环境必须的信息,当中包含进 ...
- package & import
/* * package:声明源文件所在的包,写在程序的第一行. * 每“.”一次,表示一层文件目录. * 包名都要小写. * * import: * 1)显式导入指定包下的类或接口 * 2)写在包的 ...
- PostgreSQL 系统表
postgres=# \d pg_class Table "pg_catalog.pg_class" Column | Type | Modif ...
- webpack 读取文件变量
1.webpack 获取文件中变量 <%= htmlWebpackPlugin.options.title %> <p><%= htmlWebpackPlugin.opt ...