E. Half-consecutive Numbers
题目还不能看,先贴代码过来,基本就是打表找规律
code:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
int main()
{
long long a[1000]={0,1,6};
long long b[1000],n;
int i,j;
for(j=3;1;j++)
{
a[j]=a[j-1]*6-a[j-2];
if(a[j]>1e17)break;
}
for(i=1;i<=j;i++)
{
b[i]=(long long)(a[i]*sqrt(2));
}
int t,o;
scanf("%d",&t);
for(o=1;o<=t;o++)
{
scanf("%lld",&n);
for(i=1;b[i]<n;i++);
printf("Case #%d: %lld\n",o,b[i]);
}
return 0;
}