Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

TLE...大牛们来看看(Code in C++)

Posted by Skies at 2009-07-05 23:15:18 on Problem 1519
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator