找规律,发现从f(8)%3开始又循环f(0)%3-f(7)%3的结果,由于f(2)%3==0,f(6)%3==0
所以有以下代码:
1 #include <iostream>
2 using namespace std;
3 int main()
4 {
5 int n;
6 while(cin>>n)
7 {
8 if(n%8==2||n%8==6)
9 {
10 cout<<"yes"<<endl;
11 }
12 else
13 {
14 cout<<"no"<<endl;
15 }
16 }
17 return 0;
18 }
19
2 using namespace std;
3 int main()
4 {
5 int n;
6 while(cin>>n)
7 {
8 if(n%8==2||n%8==6)
9 {
10 cout<<"yes"<<endl;
11 }
12 else
13 {
14 cout<<"no"<<endl;
15 }
16 }
17 return 0;
18 }
19