hdu 5585 Numbers

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

思路:对于2和5只须看最后一位数,对于三看所有位的数字之和就行

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<stdlib.h>
 4 #include<string.h>
 5 #include<iterator>
 6 #include<iostream>
 7 #include<algorithm>
 8 #include<set>
 9 #include<map> 
10 using namespace std;
11 
12 int main()
13 {
14     string str;
15     __int64 sum,len,a;
16     while(cin>>str)
17     {
18         sum=0;
19         len=str.length();
20         for(int i=0;i<len;i++)
21             sum+=str[i]-'0';
22         a=str[len-1]-'0';
23         if(a%2==0 || a%5==0 || sum%3==0)
24             printf("YES
");
25         else
26             printf("NO
");
27         //cout<<sum<<endl;
28     }
29     return 0;
30 }
原文地址:https://www.cnblogs.com/pter/p/5006069.html