互联网码农

关注

Digital Roots

互联网码农

关注

阅读 122

2022-05-25

1 #include <iostream>
2 #include <algorithm>
3 #include <cstring>
4 #include <string>
5 #include <cmath>
6 using namespace std;
7 int test(int x)
8 {
9 int sum=0;
10 while(x){
11 sum+=x%10;
12 x/=10;
13 }
14 sum+=x;
15 return sum;
16 }
17 int main()
18 {
19 int n;
20 while(cin>>n){
21 if(n<10) cout<<n<<endl;
22 else{
23 while(n>=10){
24 n=test(n);
25 }
26 cout<<n<<endl;
27 }
28 }
29 return 0;
30 }





相关推荐

8052cf60ff5c

HDOJ  1013   Digital Roots

8052cf60ff5c 55 0 0

爱我中华8898

HDU 1013 Digital Roots

爱我中华8898 62 0 0

夕颜合欢落

hdu 1013 Digital Roots(模拟 || 数论)

夕颜合欢落 54 0 0

ZSACH

HDU 1013 Digital Roots(模拟计算)

ZSACH 57 0 0

十日十月Freddie

HDU 1163 Eddy's digital Roots

十日十月Freddie 85 0 0

大柚子top

hdu 1163 Eddy's digital Roots

大柚子top 70 0 0

爱奔跑的读书者

HDOJ 1013题Digital Roots 大数,9余数定理

爱奔跑的读书者 63 0 0

佃成成成成

HDU 1163 Eddy's digital Roots(九余数定理)

佃成成成成 70 0 0

早安地球

Digital Roots(杭电1013)(字符串处理)(大数)

早安地球 78 0 0

南陵王梁枫

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

南陵王梁枫 66 0 0

精彩评论(0)

0 0 举报