NumbersTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 271 Accepted Submission(s): 186
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
Sample Output
|
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
char str[35];
int main()
{
int i,l;
while(scanf("%s",str)!=EOF){
l=strlen(str);
int sum=0;
for(i=0;i<l;++i){
sum+=str[i]-'0';
}
if(sum%3==0){
printf("YES\n");
}
else if((str[l-1]-'0')%2==0||str[l-1]=='5'){
printf("YES\n");
}
else {
printf("NO\n");
}
}
return 0;
}