博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Numbers HDU - 5585
阅读量:4046 次
发布时间:2019-05-25

本文共 731 字,大约阅读时间需要 2 分钟。

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<10^30)

Output

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

Sample Input

2 3 5 7

Sample Output

YES YES YES NO

题意: 

水题。但是要注意的是N是小于10^30,非常大,所以可以用字符数组来存储。

如果N的各个位的数字之和%3==0,那么就是3的倍数。

例:

123%3==0 ,1+2+3=6%3==0

789%3==0 ,7+8+9=24%3==0

55%3!=0 ,5+5=10%3!=0

如果N的个位数%2==0,那么就是2的倍数。

如果N的个位数%5==0,那么就是5的倍数。

代码:

#include
#include
#include
#include
using namespace std;int main(){ char s[107]; while(scanf("%s",s)!=EOF) { int len=strlen(s); int sum=0; for(int i=0;i

 

转载地址:http://yvzci.baihongyu.com/

你可能感兴趣的文章
Linux 粘滞位 suid sgid
查看>>
C#控件集DotNetBar安装及破解
查看>>
Winform皮肤控件IrisSkin4.dll使用
查看>>
Winform多线程
查看>>
C# 托管与非托管
查看>>
Node.js中的事件驱动编程详解
查看>>
mongodb 命令
查看>>
MongoDB基本使用
查看>>
mongodb管理与安全认证
查看>>
nodejs内存控制
查看>>
nodejs Stream使用中的陷阱
查看>>
MongoDB 数据文件备份与恢复
查看>>
数据库索引介绍及使用
查看>>
MongoDB数据库插入、更新和删除操作详解
查看>>
MongoDB文档(Document)全局唯一ID的设计思路
查看>>
mongoDB简介
查看>>
Redis持久化存储(AOF与RDB两种模式)
查看>>
memcached工作原理与优化建议
查看>>
Redis与Memcached的区别
查看>>
redis sharding方案
查看>>