题目 //好一道水水题,可是我居然也错了那么多次,后来百度来发现是因为数据数位可能很长很长,要用字符串数组... //简单 //有坑啊——数据可能很大很大,要用字符串表示! #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int main() { ]; while(scanf("%s",s)!=EOF) { )break; //无论如何,加一遍…
原题链接 题目大意:给一个数字,每一位相加求和,不断重复过程,直到剩一位数字. 解法:考虑到输入的数字可以很大,把输入按照字符串格式读入,再逐位处理. 参考代码: #include <iostream> #include <string> using namespace std; int main(){ string str; int sum,sum2,i; while(cin>>str&&str!="0"){ sum=0; for(…
Digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 79339    Accepted Submission(s): 24800 Problem Description The digital root of a positive integer is found by summing the digits of…
Digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 79180    Accepted Submission(s): 24760 Problem Description The digital root of a positive integer is found by summing the digits of…
水题记录: 注:此题题目并没有限定数值的大小,所以要用字符串进行处理 #include <stdio.h> #include <string.h> int main() { ]; ")) { int len=strlen(n); ; ;i<len;i++) sum+=n[i]-'; ) printf("%d\n",sum); else { ) { ; while(sum) { tmp+=sum%; sum/=; } sum=tmp; } prin…
Digital Roots Problem Description The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits,…
Digital Roots Problem Description The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits,…
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 57857 Accepted Submission(s): 18070 Problem Description The digital root of a positive integer is found by summing the digits of the i…
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5783    Accepted Submission(s): 3180 Problem Description The digital root of a positive integer is found by summing the digit…
Problem Description The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits a…