hdu 5585 水题 Numbers 2015.11.28 bestcoder 1001
来源:互联网 发布:特别想找个女朋友知乎 编辑:程序博客网 时间:2024/06/05 22:44
题意:给一个长度最多为30的数,问是否能被2,3或者5整除
思路:按照字符串存储,判断最后一个数是不是2的倍数、5,以及判断各个位相加是否能被3整除
Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 130 Accepted Submission(s): 86
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)
<pre name="code" class="cpp">#include <iostream>#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string>#include <string.h>#include <algorithm>#include <vector>#include <queue>#include <iomanip>#include <time.h>#include <set>#include <map>#include <stack>using namespace std;typedef long long LL;const int INF=0x7fffffff;const int MAX_N=10000;//long long n;char A[100];int main(){ while(scanf("%s",&A)!=EOF){ if(A[strlen(A)-1]=='0'||A[strlen(A)-1]=='5'){ printf("YES\n"); continue; } if((A[strlen(A)-1]-'0')%2==0){ printf("YES\n"); continue; } int ans=0; for(int i=0;i<strlen(A);i++){ ans+=A[i]-'0'; } if(ans%3==0){ printf("YES\n"); continue; } else printf("NO\n"); } return 0;}
1 0
- hdu 5585 水题 Numbers 2015.11.28 bestcoder 1001
- BestCoder Round #64 (div.2) 1001 Numbers HDU 5585 模拟
- BestCoder Round #64 (div.2) A Numbers&&HDU 5585
- HDU 5585 Numbers(字符串的处理 简单题)——BestCoder Round #64(div.2)
- hdu 5586 Sum 2015.11.28 bestcoder 1002
- hdu 5587 Array 2015.11.28 bestcoder 1003
- HDU BestCoder 1001
- HDU-5108-Alexandra and Prime Numbers (BestCoder Round #19)
- hdu 5505 GT and numbers【BestCoder Round #60】
- HDU BestCoder Round #48 1001
- HDU 5104 Bestcoder #18 1001 Primes Problem 水题
- Hdu 5585 Numbers
- HDU 5585 Numbers
- HDU 5585 Numbers
- HDU 6168 Numbers【水题】
- HDU 5272 Dylans loves numbers——BestCoder Round #45(模拟)
- HDU 5522 Numbers(暴力)——BestCoder Round #61(div.2)
- BestCoder round#3 1001 && Hdu 4907
- HDU 5586 Sum (dp)
- IO流之----字节流(InputStream和OutputStream)
- 如何解决Windows 10超级管理员账号权限受限的问题
- 热膨胀和热传导
- Android程序反编译-1
- hdu 5585 水题 Numbers 2015.11.28 bestcoder 1001
- 布隆过滤器初识
- Handler Looper Message的源码分析
- Single Number II
- ccf 字符串匹配
- ActiveMQ和JMS的使用
- recyclerview出现的问题
- 实时搜索引擎Elasticsearch(5)——Java API的使用
- HDU 5587 Array (规律)