hdu acm 1005

  1. #include <stdio.h>
  2. #include <iostream>
  3. using namespace std;
  4. int f(int n, int A, int B)
  5. {
  6. if(n==1) return 1;
  7. else if(n==2) return 1;
  8. else
  9. return (A * f(n - 1, A, B) + B * f(n - 2, A, B)) % 7;
  10. }
  11. int main()
  12. {
  13. for(int i=1; i<50; i++)
  14. {
  15. printf("%d ", f(i, 1, 2) );
  16. if(i % 10 ==0)
  17. printf("\n");
  18. }
  19. return 0;
  20. }





附件列表

     

    posted @ 2015-01-29 15:41  sober_reflection  阅读(108)  评论(0编辑  收藏  举报