LightOJ 1008 Fibsieve`s Fantabulous Birthday
来源:互联网 发布:淘宝假冒商品申诉材料 编辑:程序博客网 时间:2024/05/07 16:33
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 <stdio.h>#include <math.h>int main(){ int t,x,y,cas=0; long long s,n,num; scanf("%d",&t); while(t--) { scanf("%lld",&s); n=sqrt(s); if(s>(n*n)) n++; num=n*n-(n-1); if(n%2==1) { if(s>num) { x=n-(s-num); y=n; } else { y=n-(num-s); x=n; } } else { if(s>num) { y=n-(s-num); x=n; } else { x=n-(num-s); y=n; } } printf("Case %d: %d %d\n",++cas,x,y); } return 0;}
- lightoj 1008 - Fibsieve`s Fantabulous Birthday
- LightOJ 1008 - Fibsieve`s Fantabulous Birthday
- lightOJ 1008 - Fibsieve`s Fantabulous Birthday
- LightOJ 1008 - Fibsieve`s Fantabulous Birthday (规律)
- 【思维】LightOj Fibsieve`s Fantabulous Birthday 1008
- LightOJ-1008 Fibsieve`s Fantabulous Birthday
- 1008 - Fibsieve`s Fantabulous Birthday (lightoj)
- lightoj 1008 - Fibsieve`s Fantabulous Birthday 乱搞
- LightOJ 1008 Fibsieve`s Fantabulous Birthday
- Lightoj 1008 - Fibsieve`s Fantabulous Birthday
- LightOJ 1008 Fibsieve`s Fantabulous Birthday
- 【LightOJ 1008 Fibsieve`s Fantabulous Birthday】
- lightoj 1008 - Fibsieve`s Fantabulous Birthday
- LightOJ-1008-Fibsieve`s Fantabulous Birthday [规律]
- lightoj 1008 - Fibsieve`s Fantabulous Birthday 【数学 找规律】
- lightoj--1008--Fibsieve`s Fantabulous Birthday(水题)
- 【LightOJ】1008 - Fibsieve`s Fantabulous Birthday(规律)
- lightoj-1008 - Fibsieve`s Fantabulous Birthday【思维】【找规律】
- E法律、法规、标准化
- [iOS]NSOperation的start与main,并发与非并发。
- After upgrading to Gradle 2.0: Could not find property 'Compile' on root project
- Oracle 数据库SQL中 decode()函数简介
- uvalive 6693 - Flow Game - BFS
- LightOJ 1008 Fibsieve`s Fantabulous Birthday
- 对菜鸟开发者的忠告:花一万个小时练习 Coding,不要浪费一万小时无谓地 Debugging
- Flex 在TextInput里输入值,对datagrid进行数据筛选
- OC高度总结
- php以数组形式获得配置文件数据示例详解
- 理解Java 8 Lambda
- javaSE 面向对象复习(一)
- LightOJ 1043 - Triangle Partitioning
- [bzoj1042][HAOI2008]硬币购物