Hdu 5585 Numbers

简介:

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)
 

Output
For each test case,output the answer in a line.
 

Sample Input
 
 
2 3 5 7
 

Sample Output
 
 
YES YES YES NO
 

Source
 

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;
}


目录
相关文章
|
2月前
|
Java 测试技术
hdu 1228 A + B
hdu 1228 A + B
18 0
|
人工智能 Java
hdu 1712 ACboy needs your help
ACboy这学期有N门课程,他计划花最多M天去学习去学习这些课程,ACboy再第i天学习第j门课程的收益是不同的,求ACboy能获得的最大收益。
113 0
|
定位技术
hdu 4771 Stealing Harry Potter's Precious
点击打开链接 题意:题目给定一个n*m的地图,地图有一个起点标记为'@',还有'#'表示不能够走的,'.'表示可以走。给定k个点,问从起点开始把这k个点走过去的最小步数。
769 0