zoukankan      html  css  js  c++  java
  • Fibsieve`s Fantabulous Birthday LightOJ

    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 %lld
    ", ++kase, m, m);
            else if(x < m)
            {
                if((m*m) & 1)
                    printf("Case %d: %lld %lld
    ", ++kase, x, m);
                else
                    printf("Case %d: %lld %lld
    ", ++kase, m, x);
            }
            else
            {
                if((m*m) & 1)
                    printf("Case %d: %lld %lld
    ", ++kase, m, (2*m - x));
                else
                    printf("Case %d: %lld %lld
    ", ++kase, (2*m - x), m);
            }
    
    
    
        }
    
    
    
    
        return 0;
    }
    View Code
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    使用反射和HttpServlet类制作一个简单的web层框架
    [剑指offer]跳台阶问题&动态规划求解
    [剑指offer]旋转数组的最小值
    java实现大锤的自动校对程序(字节校招,字符串问题)
    栈结构的java实现&括号匹配问题
    单链表结构及链表反转操作java代码实现
    排序算法的java实现
    Ajax+JSON
    Jquery
    Filter+Listener
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/9350831.html
Copyright © 2011-2022 走看看