lightOJ 1008 - Fibsieve`s Fantabulous Birthday

原创 2015年11月18日 22:55:30

看成正方形,每个就是1,2,3,4,5...的平方围成的图形,然后就可以找到规律了

#include <iostream>
#include <cstdio>
#include <cmath>
 
using namespace std;
 
int main()
{
    int T,cas=0;
    cin >> T;
    while(T--)
    {
        long long num;
        cin >> num;
        double tmp = sqrt(double(num));
        tmp = tmp==(int)tmp?tmp:tmp+1;
        long long pos=(long long)tmp;
        printf("Case %d: ",++cas);
        if(pos&1)
        {
            if(num > pos*pos-pos)
                printf("%lld %lld\n",pos*pos-num+1,pos);
            else
                printf("%lld %lld\n",pos,num-(pos-1)*(pos-1));
        }
        else
        {
            if(num > pos*pos-pos)
                printf("%lld %lld\n",pos,pos-(num-(pos*pos-pos+1)));
            else
                printf("%lld %lld\n",num-(pos-1)*(pos-1),pos);
        }
    }
    return 0;
}


</pre><pre>
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

LightOJ 1008 - Fibsieve`s Fantabulous Birthday

Fibsieve had a fantabulous (yes, it's an actual word)birthday party this year. He had so many gifts ...

LightOJ1008---Fibsieve`s Fantabulous Birthday (规律)

Fibsieve had a fantabulous (yes, it’s an actual word) birthday party this year. He had so many gifts...

lightoj 1008 - Fibsieve`s Fantabulous Birthday

Fibsieve had a fantabulous (yes, it's an actual word)birthday party this year. He had so many gifts ...

Light oj:1008 - Fibsieve`s Fantabulous Birthday【规律】

1008 - Fibsieve`s Fantabulous Birthday PDF (English) Statistics Forum ...

Light OJ 1008- Fibsieve`s Fantabulous Birthday

直接模拟: #include #include using namespace std; int main() { int t; scanf("%d",&t); for(int ca=1...

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

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

Light OJ 1008 Fibsieve`s Fantabulous Birthday(找出数字位置)

Fibsieve had a fantabulous (yes, it's an actual word) birthday party this year. He had so many gifts...

Light OJ 1008 Fibsieve`s Fantabulous Birthday【规律】

1008 - Fibsieve`s Fantabulous Birthday PDF (English) Statistics Forum Time Limit: 0.5 s...
  • wyjwyl
  • wyjwyl
  • 2015年12月01日 19:44
  • 149

LIGHTOJ-10081008 - Fibsieve`s Fantabulous Birthday(规律)

1008 - Fibsieve`s Fantabulous Birthday PDF (English) Statistics Forum ...
  • nvliba
  • nvliba
  • 2015年12月04日 11:43
  • 251

Fibsieve`s Fantabulous Birthday

Description Fibsieve had a fantabulous (yes, it's an actual word) birthday party this year. He ha...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:lightOJ 1008 - Fibsieve`s Fantabulous Birthday
举报原因:
原因补充:

(最多只允许输入30个字)