记录编号 32823 评测结果 AAAAAAAAAA
题目名称 产生01串 最终得分 100
用户昵称 Gravatarmagic 是否通过 通过
代码语言 C++ 运行时间 0.042 s
提交时间 2011-11-08 16:18:17 内存使用 0.27 MiB
显示代码纯文本
#include<cstdio>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
	int n;
	unsigned long long f[150],g[150];
	unsigned long long a,b;
unsigned long long search(unsigned long long m,int num);	
unsigned long long search(unsigned long long m,int num)
{
    if(m == 0) return 0;
    if(m == f[num]) return g[num];
    if(m <= f[num-1]) return search(m,num-1);
    else return(g[num-1] + search(m-f[num-1], num-2));
}
int main()	
{
	freopen("infinit.in","r",stdin);
	freopen("infinit.out","w",stdout);
	f[0]=1;g[0]=0;
	f[1]=1;g[1]=1;
	for (int i=2;i<=92;i++)
	{
		f[i]=f[i-1]+f[i-2];
		g[i]=g[i-1]+g[i-2];
	}
	scanf("%d",&n);
	unsigned long long x,y;
	for (int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a,&b);
		x=search(a-1,92);
		y=search(b,92);
		printf("%lld\n",y-x);
	}
	return 0;
}