Hdu oj 1013 Digital Roots
来源:互联网 发布:知乎毕业设计单片机 编辑:程序博客网 时间:2024/05/07 06:30
题目:点击打开链接
分析:用数组模拟大数。
九余数定理:一个数模9等于各位数字和模9,例如 33%9=6%9;
代码一:
#include<stdio.h>char str[2000];int main(){int a;while(scanf("%s",str)){int i;int a=0,b=0;if(str[0]=='0')break;for(i=0;str[i]!='\0';i++)a+=str[i]-'0';while(1){b+=a%10;a=a/10;if(a/10==0)b+=a;if(a/10==0&&b/10==0)break;if(a/10==0&&b/10!=0){a=b;b=0;}}printf("%d\n",b);}return 0;}
代码二:九余数定理
#include <stdio.h>#include <string.h>int main(){ char s[1003]; int i; int a; while(scanf("%s",s),s[0]!='0') { a=0; for(i=0;s[i]!='\0';i++) a=a*10+s[i]-'0',a=a%9; if(a==0) a=9; printf("%d\n",a); } return 0;}
0 0
- hdu-oj 1013 Digital Roots
- hdu-oj 1013 Digital Roots
- Hdu oj 1013 Digital Roots
- HDU OJ Digital Roots 题目1013
- hdu oj 1013 Digital Roots 解题报告
- hdu oj 1013 Digital Roots(dfs)
- HDU 1013 Digital Roots
- HDU 1013 Digital Roots
- hdu 1013 Digital Roots
- HDU 1013 Digital Roots
- HDU 1013 Digital Roots
- HDU 1013 Digital Roots
- hdu 1013 Digital Roots
- HDU 1013 Digital Roots
- hdu 1013 Digital Roots
- HDU--1013--Digital Roots
- hdu 1013 Digital Roots
- hdu 1013 Digital Roots
- Java反射浅谈
- 山科大牛总结
- iOS开发之OC实例可见度,方法
- 在freemarker的模板文件中调用自定义的方法
- leetcode--83&82 Remove Duplicates from sorted list I&II
- Hdu oj 1013 Digital Roots
- 快速排序算法
- hdu 5373 The shortest problem 清晰的思路比什么都重要
- Win10开发:视觉状态VisualState与自适应UI
- 静态链接的一点小总结(一) 《程序员的自我修养》·笔记
- 话务预测(3) ARIMA
- Linux strace命令
- NSString和NSArray平时练习总结
- Eclipse快捷键及各种设置