| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
TLE...大牛们来看看(Code in C++)#include <iostream>
#include <string>
using namespace std;
int main()
{
string n;
int x,s,i;
while(cin>>n){
if(n=="0")break;
for(i=0,x=0;i<n.length();i++){
x+=n[i]-'0';
}
s=0;
while(x>=10){
while(x>0){
s+=x%10;
x/=10;
}
x=s;
}
cout<<x<<endl;
}
return 0;
}
这也能TLE? Help!
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator