Hdu 5585 Numbers
来源:互联网 发布:p2p网贷数据库设计 编辑:程序博客网 时间:2024/06/07 12:00
Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 217 Accepted Submission(s): 151
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.
Output
For each test case,output the answer in a line.
Sample Input
2357
Sample Output
YESYESYESNO
Source
BestCoder Round #64 (div.2)
Recommend
hujie | We have carefully selected several similar problems for you: 5589 5588 5584 5583 5582
题目大意:
给一个数N,如果N是2、3或者5的倍数,输出"YES",否则输出"NO".
解体思路:
注意数据范围,用字符串来做。。。比较水代码:
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <vector>#include <queue>#include <algorithm>#include <set>using namespace std;#define MM(a) memset(a,0,sizeof(a))typedef long long LL;typedef unsigned long long ULL;const int maxn = 1e5+5;const int mod = 1e4+7;const double eps = 1e-10;const int INF = 0x3f3f3f3f;LL gcd(LL a, LL b){ if(b == 0) return a; return gcd(b, a%b);}char str[maxn];int main(){ while(cin>>str) { int len = strlen(str); LL sum = 0; for(int i=0; i<len; i++) sum += str[i]-'0'; if(sum%3==0 || (str[len-1]-'0')%2==0 || str[len-1]-'0'==5) puts("YES"); else puts("NO"); } return 0;}
0 0
- Hdu 5585 Numbers
- HDU 5585 Numbers
- HDU 5585 Numbers
- HDU-5585 Numbers(数学)
- hdu 5585 Numbers(水)
- Numbers HDU
- hdu 5585 Numbers(字符串模拟大数)
- HDU 3117 Fibonacci Numbers
- hdu 3117 Fibonacci Numbers
- HDU 1058 Humble Numbers
- hdu 1390 Binary Numbers
- hdu 1058 Humble Numbers
- hdu 1128 Self Numbers
- hdu 3117 Fibonacci Numbers
- hdu 1058 Humble Numbers
- HDU 1128 self numbers
- HDU 1390 Binary Numbers
- HDU Humble Numbers
- 二维码图片生成(扩展知识:创建带圆角效果的图片) CIFilter
- 使用CIFilter生成二维码并自定义
- Intellij Idea 将java项目打包成jar
- iOS开发 - 二维码的生成与读取
- 【Android】LocalBroadcastManager 注册的广播对 PendingIntent 无效
- Hdu 5585 Numbers
- .net下调用K3登录界面的方法
- 1025. PAT Ranking (25)
- Lua封装复制Table并不关联
- 游乐场
- 好奇心和求知欲是什么
- 所有的错误都是精心包装的礼物
- 关于(C#).net下调用金蝶查询界面
- 【JAVA】RMI远程控制访问对象代码示例