题目描述

给定一个很大的整数,我想知道它能否被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的更多相关文章

  1. ffmpeg按比例缩放--"width / height not divisible by 2" 解决方法

    最近在处理视频的时候,有这么一个需求 如果视频的分辨率宽度大于960的话,就把宽度设为960,而高度按其比例进行缩放 如果视频的分辨率高度大于540的话,就把高度设为540,而宽度按其比例进行缩放 之 ...

  2. LeetCode "Largest Divisible Subset" !

    Very nice DP problem. The key fact of a mutual-divisible subset: if a new number n, is divisible wit ...

  3. 17110 Divisible(basic)

    17110 Divisible 时间限制:1000MS  内存限制:65535K 题型: 编程题   语言: 无限制 Description Given n + m integers, I1,I2,. ...

  4. HDU 1280 前m大的数

    http://acm.hdu.edu.cn/showproblem.php?pid=1280 前m大的数 Time Limit: 2000/1000 MS (Java/Others) Memory L ...

  5. project euler 12 Highly divisible triangular number

    Highly divisible triangular number Problem 12 The sequence of triangle numbers is generated by addin ...

  6. HPU周赛题目解析

    A - Wilbur and Swimming Pool Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  7. <hdu - 1280> 前M大的数 (注意其中的细节)

    这是杭电hdu上的链接http://acm.hdu.edu.cn/showproblem.php?pid=1280  Problem Description: 还记得Gardon给小希布置的那个作业么 ...

  8. [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 ...

  9. [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 ...

  10. [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 ...

随机推荐

  1. 【LeetCode】171. Excel Sheet Column Number

    题目: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, r ...

  2. 【Android Developers Training】 99. 获取联系人详细信息

    注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...

  3. linq中日期格式转换或者比较,程序报错说不支持方法的解决办法

    public void TestMethod1(){using (var _context = new hotelEntities()){var rq = DateTime.Now.Date;var ...

  4. JS数组及内置对象

    [JS中的数组]1.数组的概念:数组是在内存中连续存储多个有序元素的结构元素的顺序,称为下标,通过下标查找对应元素.2.数组的声明: ① 字面量声明: var arr1 = [];JS中同一数组,可以 ...

  5. openssl ca(签署和自建CA)

    用于签署证书请求.生成吊销列表CRL以及维护已颁发证书列表和这些证书状态的数据库.因为一般人无需管理crl,所以本文只介绍openssl ca关于证书管理方面的功能. 证书请求文件使用CA的私钥签署之 ...

  6. 简单svg动画实现

    一.将svg嵌入到html中 svg是指可伸缩矢量图形,它使用XML格式定义图像.在html中可以使用<svg>标签直接嵌入svg代码,例如: <svg version=" ...

  7. 《javascript高级程序设计》笔记七

    第五章 引用类型(三) 今天首先说的就是Function类型.下面就是定义函数的两种方法,第一种使用函数声明语法定义,第二种使用函数表达式定义.这两种定义函数的方式几乎没有什么区别. function ...

  8. Excel文件按照指定模板导入数据(用jxl.jar包)

        本文中的方法只适合Excel2003,要读取Excel2007最好使用poi.jar,据说poi.jar还在更新,jxl.jar已经不更新了,处理Excel文件的读写问题最好还是学习poi.j ...

  9. 我的学习之路_第二十七章_jQuery

    jQueryjs类库 把常用对象或者方法封装起来,让我们写代码效率更高 1.jQuery 2.extjs [jQuery入门] jQuery的引入: 通过script标签的src属性引入 入门: 获取 ...

  10. 性能百万/s:腾讯轻量级全局流控方案详解

    WeTest 导读 全新的全局流控实现方案,既解决了目前流控的实现难点,同时保证运行稳定且流控准确的前提下,实现更简单,部署成本更低,容灾能力更强. 该方案组件化之后,可以推广到别的有需要的部门使用, ...