HDU 5585(数论)

来源:互联网 发布:安装软件出现2503 编辑:程序博客网 时间:2024/05/16 19:41

Numbers

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
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
2357
 
Sample Output
YESYESYESNO
 
Source
BestCoder Round #64 (div.2)
 

#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <vector>#include <map>#include <list>#include <cmath>#include <queue>#include <stack>#include <set>#include <algorithm>#define LL long long#define INF 0x3f3f3f3f#define RR freopen("in.txt","r",stdin)#define WW freopen("out.txt","w",stdout)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;int main(){    char s[1010];    while(cin>>s)    {        int sum = 0;        int len = strlen(s);        for(int i=0; i<len; i++)            sum += (s[i] - '0');        if(sum % 3 == 0 || (s[len-1] - '0')%2==0 || s[len-1] - '0'==5)            cout<<"YES"<<endl;        else            cout<<"NO"<<endl;    }    return 0;}



0 0
原创粉丝点击