HPU--1280 Divisible
题目描述
给定一个很大的整数,我想知道它能否被9整除。
输入
有t组测试数据,每组数据给定一个整数N不存在前导0。(1 <= t <= 20,1 <= N <= 10^200)。
输出
对每组测试数据,若N可以被9整除,输出1,反之输出0。
样例输入
3
111111111111111111111111111111
6666666666666666
9999999999999999999999999999
样例输出
0
0
1
题解:能被9整出,也就是各位数字之和能被9整除
代码:
#include<cstdio>
#include<cstring>
int main()
{
int t;
char a[];
scanf("%d",&t);
while(t--)
{
scanf("%s",a);
int len=strlen(a);
int sum=;
for(int i=;i<len;i++)
sum+=a[i]-''; //这里将字符变成数字求和
if(sum%==) printf("1\n");
else printf("0\n");
}
return ;
}
HPU--1280 Divisible的更多相关文章
- ffmpeg按比例缩放--"width / height not divisible by 2" 解决方法
最近在处理视频的时候,有这么一个需求 如果视频的分辨率宽度大于960的话,就把宽度设为960,而高度按其比例进行缩放 如果视频的分辨率高度大于540的话,就把高度设为540,而宽度按其比例进行缩放 之 ...
- LeetCode "Largest Divisible Subset" !
Very nice DP problem. The key fact of a mutual-divisible subset: if a new number n, is divisible wit ...
- 17110 Divisible(basic)
17110 Divisible 时间限制:1000MS 内存限制:65535K 题型: 编程题 语言: 无限制 Description Given n + m integers, I1,I2,. ...
- HDU 1280 前m大的数
http://acm.hdu.edu.cn/showproblem.php?pid=1280 前m大的数 Time Limit: 2000/1000 MS (Java/Others) Memory L ...
- project euler 12 Highly divisible triangular number
Highly divisible triangular number Problem 12 The sequence of triangle numbers is generated by addin ...
- HPU周赛题目解析
A - Wilbur and Swimming Pool Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- <hdu - 1280> 前M大的数 (注意其中的细节)
这是杭电hdu上的链接http://acm.hdu.edu.cn/showproblem.php?pid=1280 Problem Description: 还记得Gardon给小希布置的那个作业么 ...
- [Swift]LeetCode974. 和可被 K 整除的子数组 | Subarray Sums Divisible by K
Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum ...
- [Swift]LeetCode1010. 总持续时间可被 60 整除的歌曲 | Pairs of Songs With Total Durations Divisible by 60
In a list of songs, the i-th song has a duration of time[i] seconds. Return the number of pairs of s ...
- [Swift]LeetCode1015. 可被 K 整除的最小整数 | Smallest Integer Divisible by K
Given a positive integer K, you need find the smallest positive integer N such that N is divisible b ...
随机推荐
- sqlserver isnull判断
--在新增或编辑的时候设置默认值或加isnull判断 Sql isnull函数 ISNULL(columName, 0)<>35 或 ISNULL(columName, '')<&g ...
- 不支持placeholder浏览器下对placeholder进行处理
if(document.createElement('input').placeholder !== '') { $('[placeholder]').focus(function() { var i ...
- PHP htmlspecialchars和htmlspecialchars_decode(函数)
htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体. 函数原型:htmlspecialchars(string,quotestyle,character-set) 预定 ...
- 如何使用apktool反编译,查看androidmanifest的内容
1.下载apktool http://pan.baidu.com/s/1o7Jy090 2.使用方法
- gulp 运用 的理解
ugulp.task('build', function() { runSequence('clean', 'copy', ['uglify', 'sass', 'htmlmin'], 'base64 ...
- jquery.validata.js 插件
一.Validate插件描述 Validate是基于jQuery的一款轻量级验证插件,内置丰富的验证规则,还有灵活的自定义规则接口,HTML.CSS与JS之间的低耦合能让您自由布局和丰富样式,支持in ...
- HTML5+CSS3静态页面项目-BusinessTheme的总结
因为期末考试.调整心态等等的种种原因,距离上一次的项目练习已经过了很久了,今天终于有时间继续练习HTML5+CSS3的页面架构和设计稿还原.设计图很长,整个页面分为了好几个区域,所以就不放完整的设计图 ...
- Python-Flask:利用flask_sqlalchemy实现分页效果
Flask-sqlalchemy是关于flask一个针对数据库管理的.文中我们采用一个关于员工显示例子. 首先,我们创建SQLALCHEMY对像db. from flask import Flask, ...
- Cent-Linux腾讯课堂学习笔记
RedHat yum系统下 防火墙 关闭防火墙方法 systemctl stop firewalld 检测防火墙状态 systemctl status firewalld 设置防火墙禁用开机启动 sy ...
- 添加zabbix自动发现(监控多tomcat实例)
说明 何为自动发现?首先我们监控多tomcat实例,如果一个个实例地添加或许可以完成当前需求.但是日后随着实例的增多,再手动一个个去添加就十分不方便了.这时候需要自动发现这个功能,来帮助我们自动添加监 ...