The numbers 1, 3, 6, 10, 15, 21, 28, 36, 45 and ti=21i(i+1), are called half-consecutive.
For given N, find the smallest r which is no smaller than N such that tr is square.
Input Format
The input contains multiple test cases.
The first line of a multiple input is an integer T followed by T input lines.
Each line contains an integer N (1≤N≤1016).
Output Format
For each test case, output the case number first.
Then for given N, output the smallest r.
If this half-consecutive number does not exist, output −1.
樣例輸入
4 1 2 9 50
樣例輸出
Case #1: 1 Case #2: 8 Case #3: 49 Case #4: 288
打表。必須i爲完全平方數且(i+1)/2爲完全平凡數。
//
// main.cpp
// E
//
// Created by zc on 2017/9/14.
// Copyright © 2017年 zc. All rights reserved.
//
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
ll a[21]={1,8,49,288,1681,9800,57121,332928,1940449,11309768,65918161,384199200,2239277041,13051463048,76069501249,443365544448,2584123765441,15061377048200,87784138523761,511643454094368,2982076586042449};
int main(int argc, const char * argv[]) {
/*for(ll i=1;i<=100000000;++i)
{
ll j=i*i;
if(!(j&1)) continue;
ll t=(j-1)>>1;
ll st=sqrt(t);
if(st*st==t) printf("%lld,",j-1);
t=(j+1)>>1;
st=sqrt(t);
if(st*st==t) printf("%lld,",j);
}*/
int T,kase=0;
scanf("%d",&T);
while(T--)
{
ll n;
scanf("%lld",&n);
for(int i=0;i<21;i++)
{
if(a[i]>=n)
{
printf("Case #%d: %lld\n",++kase,a[i]);
break;
}
}
}
}