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

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;
}
时间: 2024-08-31 21:09:45

Hdu 5585 Numbers的相关文章

HDU Humble Numbers

            Humble Numbers    Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1

hdu 3117 Fibonacci Numbers

点击此处即可传送到hdu 3117 **Fibonacci Numbers** Problem Description The Fibonacci sequence is the sequence of numbers such that every element is equal to the sum of the two previous elements, except for the first two elements f0 and f1 which are respectively

hdu 2138 How many prime numbers

http://acm.hdu.edu.cn/showproblem.php?pid=2138 #include <iostream> #include <cstdio> #include <cmath> using namespace std; bool isprime(int m) { if(m == 1) return 0; int n=sqrt((double)m); for(int i=2; i<=n; i++) if(m%i == 0) return 1

hdu 5505 GT and numbers【BestCoder Round #60】

GT and numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1066    Accepted Submission(s): 285 Problem Description You are given two numbers N and M. Every step you can get a new N in the w

HDOJ(HDU) 2138 How many prime numbers(素数-快速筛选没用上、)

Problem Description Give you a lot of positive integers, just to find out how many prime numbers there are. Input There are a lot of cases. In each case, there is an integer N representing the number of integers to find. Each integer won't exceed 32-

HDU 4009 Transfer water:最小树形图

链接: http://acm.hdu.edu.cn/showproblem.php?pid=4009 题目: Transfer water Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 2508    Accepted Submission(s): 934 Problem Description XiaoA lives in a vi

HDU 1535 Invitation Cards:多源点到单点最短路

链接: http://acm.hdu.edu.cn/showproblem.php?pid=1535 题目: Invitation Cards Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1044    Accepted Submission(s): 459 Problem Description In the age of te

HDU 2923 Einbahnstrasse

链接: http://acm.hdu.edu.cn/showproblem.php?pid=2923 题目: Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1117    Accepted Submission(s): 31 Problem Description Einbahnstra You just started a new

HDU 1595 find the longest of the shortest(枚举,最短路)

链接: http://acm.hdu.edu.cn/showproblem.php?pid=1595 题目: find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 667    Accepted Submission(s): 220 Problem Description Ma