HDU ACM 1021 Fibonacci Again

Fibonacci Again

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 22501    Accepted Submission(s): 10880

Problem Description
There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).
 
Input
Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000).
 
Output
Print the word "yes" if 3 divide evenly into F(n).

Print the word "no" if not.
 
Sample Input
0
1
2
3
4
5
 
Sample Output
no
no
yes
no
no
no
 
Author
Leojay
 
Recommend
JGShining
 
#include<stdio.h>
int main()
{
    int men[8], i, j, n;
    men[0] = 1;
     men[1] = 2;
     men[2] = 0;
     men[3] = 2;
     men[4] = 2;
     men[5] = 1;
     men[6] = 0;
     men[7] = 1;
    while(scanf("%d", &n) != EOF)
    {
        if(!men[n%8]) printf("yes\n");
        else printf("no\n");
    }
} 

解题报告:
  这题之前有尝试去AC他,不过一直都对题目的意思不理解,后来尝试解决时在几分钟内就AC了它,能得到的收获是冷静地分析数据,最重要的是草稿纸要干净,找到了规律就要大胆的验证,之前很少会这样做题,说实话这题是有点怀着吊儿郎当的心态提交的,后来想想也是有根据的,毕竟,规律就是这样的。

物役记

更多内容请关注个人微信公众号 物役记 (微信号:materialchains)

原文地址:https://www.cnblogs.com/liaoguifa/p/2732463.html