逐渐发现找规律的美妙之处啦,真不错,用普通方法解决很久或者很麻烦的问题,找到规律就很方便,算法最主要还是思想
Description
Input
Output
Sample Input
Sample Output
#include <stdio.h> long long a[100]; void init() { a[0] = 7; a[1] = 11; for(int i = 2; i < 100; i++) { a[i] = a[i-1]+a[i-2]; } } int main() { init(); for(int i = 0; i < 100; i++) { printf("a[%d] = %lld\n", i, a[i]); if(a[i] % 3 == 0) printf("*****\n"); } return 0; }
发现每四项有一个满足要求的,所以代码如下:
#include <stdio.h> int main() { long long n; while(scanf("%lld", &n)!= EOF) { if(n % 4 == 2) printf("yes\n"); else printf("no\n"); } return 0; }
原文:http://www.cnblogs.com/rain-1/p/4885430.html