NYOJ252 01串

来源:互联网 发布:unity3d texture 编辑:程序博客网 时间:2024/05/29 14:13

原题链接

经典题。这题可以从最基本的情况开始推,可以发现是斐波那契数列,剩下的就简单了。

附ac代码:

#include <stdio.h>int a[41] = {1, 2, 3, 5};int main(){int t, n, i;for(i = 4; i != 41; ++i)a[i] = a[i - 1] + a[i - 2];scanf("%d", &t);while(t-- && scanf("%d", &n))printf("%d\n", a[n]);return 0;}


0 0