Last active
December 12, 2015 00:19
-
-
Save Abreto/4683254 to your computer and use it in GitHub Desktop.
编程啦-Problem-1268
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Bianchengla - Problem 1268. */ | |
#include <stdio.h> | |
int count(int distance); | |
int count_val[40] = {0}; | |
int main() | |
{ | |
int N = 0; | |
int start = 0, end = 0; | |
scanf("%d\n", &N); | |
while(N--) | |
{ | |
scanf("%d %d", &start, &end); | |
printf("%d\n", count(end-start)); | |
} | |
return 0; | |
} | |
int count(int distance) | |
{ | |
if(distance <= 2) | |
return distance; | |
if( 0 == count_val[distance] ) | |
count_val[distance] = count(distance-1) + count(distance-2); | |
return count_val[distance]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment