hdu 5583 Numbers

Numbers

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2003    Accepted Submission(s): 753


Problem Description
There is a number N.You should output "YES" if N is a multiple of 2, 3 or 5,otherwise output "NO".
 

Input
There are multiple test cases, no more than 1000 cases.
For each case,the line contains a integer N.(0<N<1030)
 

Output
For each test case,output the answer in a line.
 

Sample Input
2 3 5 7
 

Sample Output
YES YES YES NO
 

#include<iostream>
#include<string>
#include<math.h>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
	string s;
	while(cin>>s)
	{
		long long int sum=0,t,i;
		t=s[s.size()-1]-'0';
		for(i=0;i<s.size();i++)
		{
			sum+=(s[i]-'0');
		}
		if(sum%3==0||t%2==0||t%5==0)
		cout<<"YES"<<endl;
		else
		cout<<"NO"<<endl; 
	}
} 


posted @ 2017-02-04 16:29  X_na  阅读(120)  评论(0)    收藏  举报