题意:求数根。

解法:一个数的数根就是mod9的值,0换成9,只是没想到给的是一个大数……只好先把每位都加起来再mod9……

代码:

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<time.h>
#include<stdlib.h>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define LL long long using namespace std; int main()
{
string s;
while(cin >> s)
{
if(s == "0") break;
int ans = 0;
for(int i = 0; i < s.size(); i++)
ans += s[i] - '0';
ans %= 9;
if(!ans) ans = 9;
cout << ans << endl;
}
return 0;
}

  

POJ 1519 Digital Roots的更多相关文章

  1. poj 1519 Digital Roots (计算根数字)

    一.Description The digital root of a positive integer is found by summing the digits of the integer. ...

  2. POJ 1519:Digital Roots

    Digital Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25766   Accepted: 8621 De ...

  3. Digital Roots 1013

    Digital Roots 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:456            测试通过:162 描述 T ...

  4. Eddy's digital Roots

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

  5. Digital Roots 分类: HDU 2015-06-19 22:56 13人阅读 评论(0) 收藏

    Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  6. HDU 1163 Eddy's digital Roots

    Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  7. ACM——Digital Roots

    http://acm.njupt.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1028 Digital Roots 时间 ...

  8. HDOJ 1163 Eddy's digital Roots(九余数定理的应用)

    Problem Description The digital root of a positive integer is found by summing the digits of the int ...

  9. Eddy's digital Roots(九余数定理)

    Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

随机推荐

  1. 数组对象Vector用法

    import java.util.Vector; public class VectorTesting { public static void main(String[] args) { Vecto ...

  2. IDataParameter[]

    IDataParameter[]简单的说来,就是可以包含任何数据库参数的数组,这些参数可以是SqlParameter或者OleDbParameter,但是,IDataParameter[]不可以直接从 ...

  3. windows cmd控制台打开和关闭SqlServer 以及 显示发生系统错误5 拒绝访问的解决方案

    打开:net start mssqlserver 关闭:net stop mssqlserver 在dos下输入 net start mssqlserver 显示发生系统错误5 拒绝访问 解决办法,以 ...

  4. Linux Shell 数字计算与比较

    直接上脚本, 使用$(())以及$[]进行数字计算 数值比较:n1 -eq n2检查n1是否等于n2         n1 -le n2检查n1是否小于等于n2n1 -ge n2检查n1是否大于等于n ...

  5. Android中ExpandableListView,每次只展示一个分组

    // 只允许打开一个分组 expandListView.setOnGroupExpandListener(new OnGroupExpandListener() { @Override public ...

  6. Python str字符串常用到的函数

    # -*- coding: utf-8 -*- x='pythonnnnnnoooo' print type(x) # <type 'str'> 输出类型 print x.capitali ...

  7. sql语句面试总结

    1.用一条SQL语句 查询出每门课都大于80分的学生姓名 name   kecheng   fenshu 张三     语文       81张三     数学       75李四     语文   ...

  8. Spring的lazy-init详解

    1.Spring中lazy-init详解ApplicationContext实现的默认行为就是在启动服务器时将所有singleton bean提前进行实例化(也就是依赖注入).提前实例化意味着作为初始 ...

  9. HTML5入门4---HTML5 与 HTML4 同一网页的不同写法

    HTML4写法 css: body { font-family: "Lucida Sans Unicode", "Lucida Grande", Verdana ...

  10. maven项目:Invalid bound statement

    在使用maven做mybatis项目时会遇到这个问题, org.apache.ibatis.binding.BindingException: Invalid bound statement (not ...