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)
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
AC代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
char s[500];
int i,n,num,sum;
while(gets(s))
{
sum=0;
n=strlen(s);
num=s[n-1]-'0';
for(i=0;i<n;i++)
{
sum+=s[i]-'0';
}
if(sum%3==0||num%5==0||num%2==0)
{
printf("YES\n");
}
else if(sum%3!=0)
{
printf("NO\n");
}
}
return 0;
}