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 ...
随机推荐
- php设计模式--命名空间与自动载入
关于命名空间: 最早的php是没有命名空间的概念的,这样不能存在相同名称的类或者函数,当项目变大了之后,产生冲突的可能性就高了,代码量也会变大,为了规划,从php5.3开始对命名空间就支持了. 说明代 ...
- undefined variable _session php
解决方法: if (version_compare(PHP_VERSION, '5.4.0', '<')) { if(session_id() == '') {session_start();} ...
- 【Android Developers Training】 72. 缩放一个视图
注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...
- Linux系统目录结构介绍
参考博客: http://www.cnblogs.com/chensiqiqi/p/6243549.html 感谢原博主为我学习Linux指明方向!! linux目录:一切从“根”开始,“/”是所有目 ...
- Server from URL
在你做网页时,如果网页需要运行ActiveX或脚本,并且他们位于客户端以外的地方, 那么可以添加这个注释语句,IE当然不会不理他, IE会按照他指出的URL去找脚本的位置. 这句话的作用是让Inter ...
- webpack的Hot Module Replacement运行机制
使用webpack打包,难免会使用Hot Module Replacement功能,该功能能够实现修改.添加或删除前端页面中的模块代码,而且是在页面不刷新的前提下.它究竟是怎么运作的呢?本文主要从调试 ...
- file里的路径
实例话file类的对象 File file=new File("d:/mydoc/hello.txt") 文件名:fileMethod.java 相对路径:fileMethod.j ...
- Data Volume 之 bind mount - 每天5分钟玩转 Docker 容器技术(39)
storage driver 和 data volume 是容器存放数据的两种方式,上一节我们学习了 storage driver,本节开始讨论 Data Volume. Data Volume 本质 ...
- 平板点餐软件编程体会---记我的Android编程之路
前言 想开发一个平板点餐系统,研究下陈江根大侠分享的一个很高水准的实例,只是个单机版无实用意义. (如需运行源码请回复联系邮箱) 实现 Mysql 数据库+Tomcat WEb服务器,使用Servle ...
- js实现图片旋转、模板文件查看图片大图之记录篇[二]
一个小小的前端需求送给大家,使用js实现图片旋转,并且点击图片能够实现规定格式的大图. 主要使用的是jQuery的delegate()方法实现图片旋转,该方法主要的功能就是给某个组件绑定一个或一组事件 ...