比赛 |
20111107 |
评测结果 |
AAAAAAAAAA |
题目名称 |
产生01串 |
最终得分 |
100 |
用户昵称 |
fanzeyi |
运行时间 |
0.000 s |
代码语言 |
C |
内存使用 |
0.00 MiB |
提交时间 |
2011-11-07 11:23:50 |
显示代码纯文本
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 93
#ifdef _WIN32
typedef unsigned __int64 bignum;
#else
typedef unsigned long long bignum;
#endif
bignum xx[MAX], yy[MAX];
bignum f(bignum a, bignum b) {
if(!a) {
return 0;
}
if(a == 2 && a == 1) {
return yy[a];
}
if(a == xx[b]) {
return yy[b];
}
if(a < xx[b]) {
return f(a, b-1);
}
return f(a - xx[b], b - 2) + yy[b];
}
int main() {
FILE *fin = fopen("infinit.in", "r");
FILE *fout = fopen("infinit.out", "w");
int n;
bignum i;
bignum a, b;
xx[1] = 1;
xx[2] = 2;
yy[1] = yy[2] = 1;
for( i = 3 ; i <= MAX ; i++ ){
xx[i] = xx[i-1] + xx[i-2];
yy[i] = yy[i-1] + yy[i-2];
}
fscanf(fin, "%d\n", &n);
for(i = 0; i < n; i++) {
#ifdef _WIN32
fscanf(fin, "%I64u %I64u", &a, &b);
fprintf(fout, "%I64u", f(b, MAX-1) - f(a - 1, MAX-1));
#else
fscanf(fin, "%llu %llu", &a, &b);
fprintf(fout, "%llu\n", f(b, MAX-1) - f(a - 1, MAX-1));
#endif
}
return 0;
}