加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Fibsieve`s Fantabulous Birthday LightOJ - 1008(找规律。。)

发布时间:2020-12-14 03:20:13 所属栏目:大数据 来源:网络整理
导读:Description 某只同学在生日宴上得到了一个N×N玻璃棋盘,每个单元格都有灯。每一秒钟棋盘会有一个单元格被点亮然后熄灭。棋盘中的单元格将以图中所示的顺序点亮。每个单元格上标记的是它在第几秒被点亮。 第一秒棋格(1,1)将被点亮,第五秒棋格(3,1)将

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 = 10010,INF = 0x7fffffff;

int main()
{
    int T,kase = 0;
    cin>> T;
    while(T--)
    {
        LL s,x,m;
        cin>> s;
        m = ceil(sqrt((double)s));

        x = m*m - s + 1;
        if(x == m)
            printf("Case %d: %lld %lldn",++kase,m,m);
        else if(x < m)
        {
            if((m*m) & 1)
                printf("Case %d: %lld %lldn",m);
            else
                printf("Case %d: %lld %lldn",x);
        }
        else
        {
            if((m*m) & 1)
                printf("Case %d: %lld %lldn",++kase,(2*m - x));
            else
                printf("Case %d: %lld %lldn",(2*m - x),m);
        }



    }




    return 0;
}
View Code

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读