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\n");
25         else
26             printf("NO\n");
27         //cout<<sum<<endl;
28     }
29     return 0;
30 }

 

转载于:https://www.cnblogs.com/pter/p/5006069.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值