A multiple of three
gives you a positive integer, you determine if it is a multiple of 3?
Input format:
input data has a T (T <= 50), representatives of T sets of data
for each set of data, an integer n-(. 1 <= n-<10 =
1000
) Note that the range of the data
output format:
For each set data output line "YES" or "nO" (without the quotes), or representative of the number is not a multiple of three
input sample:
here a given set of inputs. For example:
2
33332
123
Output Sample:
In the given here corresponding output. For example:
NO
YES
# include<stdio.h>
# include<string.h>
int main()
{
int m,n,i,j,k=0;
char ch[10001];
scanf("%d",&m);
for(n=0;n<m;n++)
{
scanf("%s",ch);
i=strlen(ch);
for(j=0;j<i;j++)
{
k+=(ch[j]-'0');
}
if(k%3==0)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
k=0;
}
return 0;
}
Note this Title: Characteristics of a multiple of 3, the number on each digit of the sum is a multiple of 3.