转载来自http://blog.csdn.net/wang907553141/article/details/52294090
1008 - Fibsieve`s Fantabulous Birthday
    PDF (English) Statistics Forum
Time Limit: 0.5 second(s) Memory Limit: 32 MB

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

Output for Sample Input

3

8

20

25

Case 1: 2 3

Case 2: 5 4

Case 3: 1 5

题解:刚开始想这道题太麻烦没简化,就TLE,后来再一看,ZZ 啊刚开始就找了个对角线规律,规律都没找全面怪不得TLE

题解:蓝色的是 奇数的平方;红色的是 偶数的平方;黄色的是对角线:对角线满足规律 n * (n - 1)+ 1,其中 n 为行(列)数; 然后注意一下特殊情况就行了

嗯个人理解表示我找不到规律    嗯副对角线的规律需要稍微在理解下

就是分清楚他的平方根是奇数还是偶数

因为在偶数和奇数的排列是有些不同的  楼主讲的很好可以

觉得有点不好找出来

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define LL long long
using namespace std;
LL n;
int main()
{int t;scanf("%d",&t);for(int o=1;o<=t;o++){printf("Case %d: ",o);scanf("%lld",&n);LL b,a=(LL)sqrt(n);if(a*a==n) //特殊情况{if(a&1)printf("1 %lld\n",a);//是奇数的话 那么就在第一列了elseprintf("%lld 1\n",a);//是偶数的话  那么就在第一行了continue;}//这边可以理解 这个是平方的规律/*     那个数字表示平方根 假设那个数字是3 那么   a=3  b=3*4+1=13是奇数 并且11<13那么为   2,4假设那个数字是3  那么   a=13  b=15是奇数 并且15>=13 则为   4,2 假设是 4 是偶数 那么a=4 b=2124>=21   2  5假设是 4 是偶数 则为5,218<=21 那么 5,2*/    if(a&1)//如果这个是数是奇数的话{b=a*(a+1)+1;if(n<b)printf("%lld %lld\n",a+1-(b-n),a+1);elseprintf("%lld %lld\n",a+1,a+1-(n-b));}else{b=a*(a+1)+1;if(n<b)printf("%lld %lld\n",a+1,a+1-(b-n));elseprintf("%lld %lld\n",a+1-(n-b),a+1);}}return 0;
}

1008 - Fibsieve`s Fantabulous Birthday相关推荐

  1. Light OJ - 1008 - Fibsieve`s Fantabulous Birthday 题解

    就是计算特殊长方形坐标的问题,这类题目需要的是细心,细心,再细心,然后推导摸索出公式来, 题目如下: Fibsieve had a fantabulous (yes, it's an actual w ...

  2. 【ACM】LightOJ - 1008 Fibsieve`s Fantabulous Birthday (找规律,找...)

    https://vjudge.net/problem/LightOJ-1008 题目很好理解,第一行表示测试样例的个数,接下来输入一个大于等于1的数,按照格式输出这个数的坐标     蓝色的是 奇数的 ...

  3. 大一集训题i题生日聚会lightoj-1008 - Fibsieve`s Fantabulous Birthday

    大一集训题i题生日聚会lightoj-1008 - Fibsieve`s Fantabulous Birthday **大一集训题i题生日聚会lightoj-1008 - Fibsieves Fant ...

  4. lightoj刷题日记

    开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: ----------------- 必须要update了... so...板刷第二页搞呀--2017/4/17 ...

  5. 常用技巧 —— 打表规律

    [概述] 找规律是一种常见的题型,当给出相关数据后,我们往往可以利用打表的方法,得到大量的数据,然后再寻找规律. 简单来说,打表就是需要对某个范围内的数据进行判断,判断它是否符合某种条件,然后在接下来 ...

  6. 1008: [HNOI2008]越狱(计数问题)

    1008: [HNOI2008]越狱 Time Limit: 1 Sec  Memory Limit: 162 MB Submit: 11361  Solved: 4914 [Submit][Stat ...

  7. 一口气发布1008种机器翻译模型,GitHub最火NLP项目大更新

    2020-05-18 16:20:21 鱼羊 发自 凹非寺 量子位 报道 | 公众号 QbitAI 现在,你可以用 GitHub 上最火的 NLP 项目做机器翻译了. 没错,就是 Hugging Fa ...

  8. 1008. 数组元素循环右移问题 (20)

    原题: https://www.patest.cn/contests/pat-b-practise/1008 题意理解: 假设n=6, 需要移位的序列是: 1 2 3 4 5 6, 如果m=2, 从6 ...

  9. 一口气发布1008种机器翻译模型,GitHub最火NLP项目大更新:涵盖140种语言组合

    鱼羊 发自 凹非寺 量子位 报道 | 公众号 QbitAI 现在,你可以用 GitHub 上最火的 NLP 项目做机器翻译了. 没错,就是 Hugging Face (抱抱脸)标星 26.9k 的 T ...

  10. HDU 1008 Elevator

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1008 纯水题,就是要注意即使下一站是同一楼层也要停5秒 贴上代码: 1 #include <io ...

最新文章

  1. Golang的interface实践
  2. python画人脸关键点
  3. 图的遍历递归和非递归实现
  4. Java 大数类BigInteger与BigDecimal详细介绍(配蓝桥杯例题讲解)
  5. NCHW与NC4HW4数据排布在卷积优化上的优劣分析
  6. 转载:Yahoo推出视频标签游戏
  7. amazon 设计 4 vending machine
  8. Microsoft Visual Studio使用NodeJS
  9. 求树中某结点的父结点(长子-兄弟表示法)
  10. SQL server 表中如何创建索引?
  11. Android Realm(数据库)
  12. 麦子学院3天带你学会Apple Watch开发
  13. OpenV$P$N配置后启动服务发生错误排错
  14. 方方格子Excel工具箱的使用教程
  15. 事业单位资产管理系统广西某单位案例:实现资产动态全过程管理
  16. 领峰:炒黄金白银的关键是掌握技巧
  17. xxxx-xx-xx系统应用(周)巡检报告模版
  18. laravel 输出最后执行sql 附:whereIn用法
  19. 这个Kaggle三项排行榜的“顶级大师”,今年17岁
  20. Silvaco学习笔记(四)毕设相关

热门文章

  1. cloudera search1.0.0环境搭建(2):利用flume-ng的MorphlineSolrSink实现近实时(NRT)搜索
  2. mysql的随机查询
  3. 360与Bing合作上线英文搜索
  4. Qt数据库集成应用封装
  5. XHTML跟HTML的区别
  6. 用c#开发微信 (4) 基于Senparc.Weixin框架的接收事件推送处理 (源码下载)
  7. 某大型银行某系统性能调优过程跟踪记录
  8. 【Ubuntu^Java】Ubuntu下JDK环境变量的配置
  9. Hibernate4实战   之   第五部分:Hibernate的事务和并发
  10. ThreadLocal的作用