杭电1021题

//主要是解题的思路
//f(0) = 7
//f(1) = 11
//因为f(n)要模3,所以我先将f(0)和f(1)模的3,所以现在是
//f(0) = 7 % 3 = 1
//f(1) =11 % 3 = 2
//f(3) = 3 % 3 = 0
//f(4) = 2 % 3 = 2
//f(5) = 2 % 3 = 2
//f(6) = 4 % 3 = 1
//f(7) = 3 % 3 = 0
//f(8) = 1 % 3 = 1

//f(9) = 1 % 3 = 1开始出现循环
//f(10)= 2 % 3 = 2
//总结得知这里的规律,n % 8 == 6 || n % 8 == 2都是yes,其他都是no
//但是上面的判断语句也可以写为:n % 4 == 3
//这就是做这题的思路了
#include <iostream>
using namespace std;
int main()
{
 int n;
 while(cin>>n)
 {
  int k = n % 8;
  if(k==2 || k==6)
  {
   cout<<"yes"<<endl;
  }
  else
   cout<<"no"<<endl;
 }
 return 0;
}

posted @ 2010-04-25 20:39  北海小龙  阅读(417)  评论(0编辑  收藏  举报