Skip to content

Instantly share code, notes, and snippets.

@Abreto
Last active December 12, 2015 00:19
Show Gist options
  • Save Abreto/4683254 to your computer and use it in GitHub Desktop.
Save Abreto/4683254 to your computer and use it in GitHub Desktop.
编程啦-Problem-1268
/* 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