杭电1021 竟然能AC!求大佬进来解答这是怎么回事

在这里插入图片描述
难道是巧合吗? 我这样做的时候刚开始是对9取模,但是不通过,最后改成了8直接AC

#include <iostream>
using namespace std;
int main(){
	int f[10];
	int n;
	while(cin>>n){
	f[0]=7%3;
    f[1]=11%3;
	for(int i=2;i<9;i++){
	 f[i]=(f[i-1]+f[i-2])%3;
	}
   if(f[n%8]==0)
     cout<<"yes"<<endl;
     else
     cout<<"no"<<endl;
	}
	
	return 0;
}
发布了44 篇原创文章 · 获赞 0 · 访问量 624

猜你喜欢

转载自blog.csdn.net/weixin_45191675/article/details/105170682