题目描述

给定一个很大的整数,我想知道它能否被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. java亿级流量电商详情页系统的大型高并发与高可用缓存架构实战视频教程

    亿级流量电商详情页系统的大型高并发与高可用缓存架构实战 完整高清含源码,需要课程的联系QQ:2608609000 1[免费观看]课程介绍以及高并发高可用复杂系统中的缓存架构有哪些东西2[免费观看]基于 ...

  2. top命令总结

    top命令主要用来观察和收集运行在系统上的进程的一些有用信息.ps只是一个快照,是ps命令执行的那一瞬间的系统中进程的快照.top则可以用于持续观察. 第一步,在命令行键入top,回车进入top管理界 ...

  3. [leetcode-629-K Inverse Pairs Array]

    Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that ...

  4. maven(二) maven项目构建ssh工程(父工程与子模块的拆分与聚合)

    前一节我们明白了maven是个什么玩意,这一节就来讲讲他的一个重要的应用场景,也就是通过maven将一个ssh项目分割为不同的几个部分独立开发,很重要,加油 --WH 一.maven父工程与子模块的拆 ...

  5. spring +springmvc+mybatis组合web.xml文件配置

    <?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://w ...

  6. JSON.parse()与JSON.stringify()的区别

    JSON.parse()[从一个字符串中解析出json对象] 例子: //定义一个字符串 var data='{"name":"goatling"}' //解析 ...

  7. Debian 8添加kali更新源并安装metasploit

    一.Debian 8添加kali更新源 中科大kali更新源: deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contr ...

  8. docker~从Dockerfile到Container的过程(终于算是OK了)

    上一文章,主要介绍Dockerfile里各参数的含义,以及在项目文件里这些内容的含义,因为大叔认为官方和网上其它文章说的有些模棱两可,不太好让大家理解,所有我又从新写了一个大白话的文章,希望可以给大家 ...

  9. 从源码的角度看Service是如何启动的

    欢迎访问我的个人博客 ,原文链接:http://wensibo.top/2017/07/16/service/ ,未经允许不得转载! 七月中旬了,大家的实习有着落了吗?秋招又准备的怎么样了呢?我依旧在 ...

  10. Android之圆点导航的两个案例(ViewPager)

    案例一效果: 布局文件: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" ...