HDU1021

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1021


又是一道水题

找数列中能被三整除的,找规律发现第2、6、10、...、2+4n 个数可以被3整除。那么读入后直接判断即可!


#include<iostream>
using namespace std;

int main()
{
	int n;
	while(cin>>n)
	{
		if(n<0) cout<<"no"<<endl;
		if(n==0 || n==1 ) cout<<"no"<<endl;
		if((n-2)%4==0) cout<<"yes"<<endl;
		if(n>2 && (n-2)%4!=0) cout<<"no"<<endl;
	}
	return 0;
}


猜你喜欢

转载自blog.csdn.net/hjq_xidian/article/details/52684082