Description

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

第一秒棋格(1,1)将被点亮,第五秒棋格(3,1)将被点亮。

现在这只同学想知道在给定的时间哪个棋格将被点亮(时间将以秒为单位给出)。题目假设N足够大。

Input

先输入一个整数T(<= 200) , 表示测试用例的组数。

每一组用例将包括一个整数S(1 ≤ S ≤ 1015),表示时间。

(注:此题中长整形的输入输出要用 %lld 格式实现)

Output

对于每组用例您必须打印用例编号和两个数字(x,y)表示列号和行号。

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 <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define rap(a, n) for(int i=1; i<=n; i++)
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff; int main()
{
int T, kase = ;
cin>> T;
while(T--)
{
LL s, x, m;
cin>> s;
m = ceil(sqrt((double)s)); x = m*m - s + ;
if(x == m)
printf("Case %d: %lld %lld\n", ++kase, m, m);
else if(x < m)
{
if((m*m) & )
printf("Case %d: %lld %lld\n", ++kase, x, m);
else
printf("Case %d: %lld %lld\n", ++kase, m, x);
}
else
{
if((m*m) & )
printf("Case %d: %lld %lld\n", ++kase, m, (*m - x));
else
printf("Case %d: %lld %lld\n", ++kase, (*m - x), m);
} } return ;
}

Fibsieve`s Fantabulous Birthday LightOJ - 1008(找规律。。)的更多相关文章

  1. Lightoj 1008【规律】

    25 24 23 22 21 10 11 12 13 20 9 8 7 14 19 2 3 6 15 18 1 4 5 16 17 然后把这个转化成: 17 18 19 20 21 10 11 12 ...

  2. light oj 1008 - Fibsieve`s Fantabulous Birthday

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

  3. LightOj 1245 --- Harmonic Number (II)找规律

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1245 题意就是求 n/i (1<=i<=n) 的取整的和这就是到找规律的题 ...

  4. LightOJ 13361336 - Sigma Function (找规律 + 唯一分解定理)

    http://lightoj.com/volume_showproblem.php?problem=1336 Sigma Function Time Limit:2000MS     Memory L ...

  5. [LOJ 1008] Fibsieve`s Fantabulous Birthday

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

  6. hdu4952 Number Transformation (找规律)

    2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transform ...

  7. hdu 3951 - Coin Game(找规律)

    这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...

  8. HDU 5703 Desert 水题 找规律

    已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...

  9. CF456B Fedya and Maths 找规律

    http://codeforces.com/contest/456/problem/B CF#260 div2 B Fedya and Maths Codeforces Round #260 B. F ...

随机推荐

  1. day2 self __init__ __str__

    1 self  谁调用指向谁自己  相当于其他语言的this #1.类名 class Cat(): #大驼峰的命名规范 #2.类的属性 #3.类的方法 def eat(self): print(&qu ...

  2. 【AHOI2013】差异

    题面 题解 $ \because \sum_{1 \leq i < j \leq n} i + j = \frac{n(n-1)(n+1)}2 $ 所以只需求$\sum lcp(i,j)$即可. ...

  3. 2762 helloparty·开车

    2762 helloparty·开车 时间限制: 1 s 空间限制: 32000 KB 题目等级 : 黄金 Gold   题目描述 Description hellokitty的一个朋友要来他家,但是 ...

  4. git clone的时候报error: RPC failed; result=18错误

    因业务需求,需要把内网gitlab仓库的地址对外网访问,在gitlab前端配置了一个nginx代理服务器,来实现需求,可以在git clone的时候报error: RPC failed错误 [root ...

  5. windows下安装,配置redis以及可视化客户端redisClient的安装及基本使用

    一. Window 下安装 下载地址:https://github.com/MSOpenTech/redis/releases. Redis 支持 32 位和 64 位.这个需要根据你系统平台的实际情 ...

  6. 【MYSQL命令】查看日志是否开启及日志过期天数

    show variables like 'log_%';show variables like '%expire_logs_days%'

  7. 关于Python的装饰器(2)

    Python中被装饰器修饰的函数,解析后会生成一个参数是被修饰函数的装饰器函数对象,可以调用,可以接受传参(如果被修饰的函数定义了参数),实际调用的时候,尽管代码里值写了被修饰的函数,被调用的却是最终 ...

  8. python 的入门

    时光匆匆,大一的时间过的很快,从大一上学期学的c开始,就感觉出c的结构很复杂,但是不可否认,学习c和汇编等涉及到系统底层知识才会有可能开发出属于自己知识产权的东西,然而,python以其简约性,丰富的 ...

  9. 【第八章】MySQL数据库备份—逻辑备份

    一.数据库备份 1.命令简介: # mysqldump -h 服务器 -u用户名 -p密码 数据库名 > 备份文件.sql1)关于数据库名: -A, --all-databases       ...

  10. [寒假学习笔记](二)Python初学

    Python 学习 python的自学从几个月前断断续续地进行,想好好利用这个寒假,好好地学一学. 回顾 已学习:基本操作.函数 已有C++的一定基础,只要注意python中比较特殊的部分就行 进入正 ...