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 ...
随机推荐
- 使用yum配置lnmp环境(CentOS7.6)
一.安装版本详情 Server: MariaDB Server version: 5.5.60-MariaDB MariaDB Server [root@ln-125 ~]# cat /etc/red ...
- Java将WKT格式的Geomotry转换成GeoJSON
一.Meven添加依赖 <!-- 引入json处理包 --> <dependency> <groupId>com.alibaba</groupId> & ...
- 转载:爱加密邀您参加5月17日深圳App开发沙龙活动
听闻,移动互联网的九大门派已集结在一起,各路顶尖高手携App修炼宝典九阴真经现身,一场席卷全国的App修炼风暴即将来临.5月17日,以“移动开发者如何白手起家.快速盈利”为主题的沙龙活动将在深圳市南山 ...
- 9种常见的Android开发错误及解决方案
整理总结了9个Android开发中的错误以及解决方案,共同探讨进步! 1. 如果你的项目的R文件不见的话,可以试下改版本号在保存,R文件不见一般都是布局文本出错导致. 2. 布局文件不可以有大写字母 ...
- RubyMine2017破解
RubyMine2017破解 学习了:https://www.7down.com/soft/172903.html 激活的时候选择 license server; 输入如下地址激活: http://i ...
- java 经常使用測试框架
1. 经常使用单元化測试框架 junit4 , TestNG 能够通过注解 @Before @After @BeforeClass @AfterClass 分别作方法与类级的初始化与结束动作. tes ...
- 为什么button在设置标题时要用一个方法,而不像lable一样直接用一个属性
为什么button在设置标题时要用一个方法.而不像lable一样直接用一个属性 原因是有时我们对 button做一次点击,须要改变button的标题.仅仅实用方法才干做到,而label是标签 ...
- Android 购物车的实现
实现了购物车的全选 全不选 选中删除 选中状态下数量添加时总价随之添加等基本功能. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L ...
- Insert Data with C# Driver
https://docs.mongodb.com/getting-started/csharp/insert/ OverView You can use the InsertOneAsync meth ...
- hpuoj--校赛--爬楼梯(模拟)
问题 E: 感恩节KK专场--爬楼梯 时间限制: 1 Sec 内存限制: 1000 MB 提交: 382 解决: 89 [提交][状态][讨论版] 题目描述 来机房比赛的时候大家都会爬楼梯,但是每 ...