ccf1035数根
#include<bits/stdc++.h>
using namespace std;
//微信请加 14808098 一起快乐学习信息学奥赛
int main() {
/*
3456, 3+4+5+6=18 , 18-> 9
// int MAX = 123456789
int sum = 0;
while(1){
while(n!=0){
int a = n%10;
sum = sum+a;
n=n/10;
}
if(sum/10!=0){
n = sum;
}else{
cout<<sum<<endl;
return 0;
}
}
*/
int n;cin>>n;//345
int sum=0;
int i=5;
while(i){
// cout<<n<<endl;
sum = 0;
while(n!=0){
int a = n%10;
sum=sum+a;
n=n/10;
}
// cout<<sum<<endl; //12
if(sum/10!=0){
n = sum;
}else{
cout<<sum<<endl;
return 0;
}
// i--;
}
//
return 0;
}