标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 68194 Accepted Submission(s): 21324
#include<iostream> #include<stdio.h> #include<string.h> using namespace std; int main() { char n [1000]; while(scanf("%s",n)&&n[0]!=‘0‘) { int t=0; for(int i=0;i<strlen(n);i++) t+=n[i]-‘0‘; long long tmp=t; long long ans=0; while(1) { while(tmp>0) { ans+=tmp%10; tmp/=10; } if(ans<10) break; tmp=ans; ans=0; } printf("%I64d\n",ans); } }
标签:
原文地址:http://www.cnblogs.com/superxuezhazha/p/5514120.html